Documentation
Classes
SplineTransformer

SplineTransformer

Generate univariate B-spline bases for features.

Generate a new feature matrix consisting of n\_splines=n\_knots + degree \- 1 (n\_knots \- 1 for extrapolation="periodic") spline basis functions (B-splines) of polynomial order=degree for each feature.

Read more in the User Guide.

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new SplineTransformer(opts?: object): SplineTransformer;

Parameters

NameTypeDescription
opts?object-
opts.degree?numberThe polynomial degree of the spline basis. Must be a non-negative integer. Default Value 3
opts.extrapolation?"linear" | "constant" | "error" | "continue" | "periodic"If ‘error’, values outside the min and max values of the training features raises a ValueError. If ‘constant’, the value of the splines at minimum and maximum value of the features is used as constant extrapolation. If ‘linear’, a linear extrapolation is used. If ‘continue’, the splines are extrapolated as is, i.e. option extrapolate=True in scipy.interpolate.BSpline (opens in a new tab). If ‘periodic’, periodic splines with a periodicity equal to the distance between the first and last knot are used. Periodic splines enforce equal function values and derivatives at the first and last knot. For example, this makes it possible to avoid introducing an arbitrary jump between Dec 31st and Jan 1st in spline features derived from a naturally periodic “day-of-year” input feature. In this case it is recommended to manually set the knot values to control the period. Default Value 'constant'
opts.include_bias?booleanIf true (default), then the last spline element inside the data range of a feature is dropped. As B-splines sum to one over the spline basis functions for each data point, they implicitly include a bias term, i.e. a column of ones. It acts as an intercept term in a linear models. Default Value true
opts.knots?ArrayLike[] | "uniform" | "quantile"Set knot positions such that first knot <= features <= last knot. Default Value 'uniform'
opts.n_knots?numberNumber of knots of the splines if knots equals one of {‘uniform’, ‘quantile’}. Must be larger or equal 2. Ignored if knots is array-like. Default Value 5
opts.order?"C" | "F"Order of output array. ‘F’ order is faster to compute, but may slow down subsequent estimators. Default Value 'C'

Returns

SplineTransformer

Defined in: generated/preprocessing/SplineTransformer.ts:25 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/preprocessing/SplineTransformer.ts:23 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/preprocessing/SplineTransformer.ts:22 (opens in a new tab)

_py

PythonBridge

Defined in: generated/preprocessing/SplineTransformer.ts:21 (opens in a new tab)

id

string

Defined in: generated/preprocessing/SplineTransformer.ts:18 (opens in a new tab)

opts

any

Defined in: generated/preprocessing/SplineTransformer.ts:19 (opens in a new tab)

Accessors

bsplines_

List of BSplines objects, one for each feature.

Signature

bsplines_(): Promise<any[]>;

Returns

Promise<any[]>

Defined in: generated/preprocessing/SplineTransformer.ts:362 (opens in a new tab)

feature_names_in_

Names of features seen during fit. Defined only when X has feature names that are all strings.

Signature

feature_names_in_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/preprocessing/SplineTransformer.ts:416 (opens in a new tab)

n_features_in_

The total number of input features.

Signature

n_features_in_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/preprocessing/SplineTransformer.ts:389 (opens in a new tab)

n_features_out_

The total number of output features, which is computed as n\_features \* n\_splines, where n\_splines is the number of bases elements of the B-splines, n\_knots + degree \- 1 for non-periodic splines and n\_knots \- 1 for periodic ones. If include\_bias=False, then it is only n\_features \* (n\_splines \- 1).

Signature

n_features_out_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/preprocessing/SplineTransformer.ts:443 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/preprocessing/SplineTransformer.ts:72 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/preprocessing/SplineTransformer.ts:76 (opens in a new tab)

Methods

dispose()

Disposes of the underlying Python resources.

Once dispose() is called, the instance is no longer usable.

Signature

dispose(): Promise<void>;

Returns

Promise<void>

Defined in: generated/preprocessing/SplineTransformer.ts:133 (opens in a new tab)

fit()

Compute knot positions of splines.

Signature

fit(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]The data.
opts.sample_weight?ArrayLikeIndividual weights for each sample. Used to calculate quantiles if knots="quantile". For knots="uniform", zero weighted observations are ignored for finding the min and max of X.
opts.y?anyIgnored.

Returns

Promise<any>

Defined in: generated/preprocessing/SplineTransformer.ts:150 (opens in a new tab)

fit_transform()

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit\_params and returns a transformed version of X.

Signature

fit_transform(opts: object): Promise<any[]>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Input samples.
opts.fit_params?anyAdditional fit parameters.
opts.y?ArrayLikeTarget values (undefined for unsupervised transformations).

Returns

Promise<any[]>

Defined in: generated/preprocessing/SplineTransformer.ts:201 (opens in a new tab)

get_feature_names_out()

Get output feature names for transformation.

Signature

get_feature_names_out(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.input_features?anyInput features.

Returns

Promise<any>

Defined in: generated/preprocessing/SplineTransformer.ts:252 (opens in a new tab)

init()

Initializes the underlying Python resources.

This instance is not usable until the Promise returned by init() resolves.

Signature

init(py: PythonBridge): Promise<void>;

Parameters

NameType
pyPythonBridge

Returns

Promise<void>

Defined in: generated/preprocessing/SplineTransformer.ts:85 (opens in a new tab)

set_output()

Set output container.

See Introducing the set_output API for an example on how to use the API.

Signature

set_output(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.transform?"default" | "pandas"Configure output of transform and fit\_transform.

Returns

Promise<any>

Defined in: generated/preprocessing/SplineTransformer.ts:292 (opens in a new tab)

transform()

Transform each feature data to B-splines.

Signature

transform(opts: object): Promise<ArrayLike[]>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]The data to transform.

Returns

Promise<ArrayLike[]>

Defined in: generated/preprocessing/SplineTransformer.ts:327 (opens in a new tab)