DocumentationClassesSequentialFeatureSelector

Class: SequentialFeatureSelector

Transformer that performs Sequential Feature Selection.

This Sequential Feature Selector adds (forward selection) or removes (backward selection) features to form a feature subset in a greedy fashion. At each stage, this estimator chooses the best feature to add or remove based on the cross-validation score of an estimator. In the case of unsupervised learning, this Sequential Feature Selector looks only at the features (X), not the desired outputs (y).

Read more in the User Guide.

Python Reference

Constructors

new SequentialFeatureSelector()

new SequentialFeatureSelector(opts?): SequentialFeatureSelector

Parameters

ParameterTypeDescription
opts?object-
opts.cv?numberDetermines the cross-validation splitting strategy. Possible inputs for cv are:
opts.direction?"forward" | "backward"Whether to perform forward selection or backward selection.
opts.estimator?anyAn unfitted estimator.
opts.n_features_to_select?number | "auto"If "auto", the behaviour depends on the tol parameter:
opts.n_jobs?numberNumber of jobs to run in parallel. When evaluating a new feature to add or remove, the cross-validation procedure is parallel over the folds. undefined means 1 unless in a joblib.parallel_backend context. \-1 means using all processors. See Glossary for more details.
opts.scoring?stringA single str (see The scoring parameter: defining model evaluation rules) or a callable (see Defining your scoring strategy from metric functions) to evaluate the predictions on the test set. NOTE that when using a custom scorer, it should return a single value. If undefined, the estimator’s score method is used.
opts.tol?numberIf the score is not incremented by at least tol between two consecutive feature additions or removals, stop adding or removing. tol can be negative when removing features using direction="backward". tol is required to be strictly positive when doing forward selection. It can be useful to reduce the number of features at the cost of a small decrease in the score. tol is enabled only when n_features_to_select is "auto".

Returns SequentialFeatureSelector

Defined in generated/feature_selection/SequentialFeatureSelector.ts:25

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/feature_selection/SequentialFeatureSelector.ts:23
_isInitializedbooleanfalsegenerated/feature_selection/SequentialFeatureSelector.ts:22
_pyPythonBridgeundefinedgenerated/feature_selection/SequentialFeatureSelector.ts:21
idstringundefinedgenerated/feature_selection/SequentialFeatureSelector.ts:18
optsanyundefinedgenerated/feature_selection/SequentialFeatureSelector.ts:19

Accessors

feature_names_in_

Get Signature

get feature_names_in_(): Promise<ArrayLike>

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

Returns Promise<ArrayLike>

Defined in generated/feature_selection/SequentialFeatureSelector.ts:480


n_features_in_

Get Signature

get n_features_in_(): Promise<number>

Number of features seen during fit. Only defined if the underlying estimator exposes such an attribute when fit.

Returns Promise<number>

Defined in generated/feature_selection/SequentialFeatureSelector.ts:453


n_features_to_select_

Get Signature

get n_features_to_select_(): Promise<number>

The number of features that were selected.

Returns Promise<number>

Defined in generated/feature_selection/SequentialFeatureSelector.ts:507


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/feature_selection/SequentialFeatureSelector.ts:77


support_

Get Signature

get support_(): Promise<ArrayLike>

The mask of selected features.

Returns Promise<ArrayLike>

Defined in generated/feature_selection/SequentialFeatureSelector.ts:534

Methods

dispose()

dispose(): Promise<void>

Disposes of the underlying Python resources.

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

Returns Promise<void>

Defined in generated/feature_selection/SequentialFeatureSelector.ts:133


fit()

fit(opts): Promise<any>

Learn the features to select from X.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]Training vectors, where n_samples is the number of samples and n_features is the number of predictors.
opts.y?ArrayLikeTarget values. This parameter may be ignored for unsupervised learning.

Returns Promise<any>

Defined in generated/feature_selection/SequentialFeatureSelector.ts:150


fit_transform()

fit_transform(opts): Promise<any[]>

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters

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

Returns Promise<any[]>

Defined in generated/feature_selection/SequentialFeatureSelector.ts:191


get_feature_names_out()

get_feature_names_out(opts): Promise<any>

Mask feature names according to selected features.

Parameters

ParameterTypeDescription
optsobject-
opts.input_features?anyInput features.

Returns Promise<any>

Defined in generated/feature_selection/SequentialFeatureSelector.ts:237


get_metadata_routing()

get_metadata_routing(opts): Promise<any>

Raise NotImplementedError.

This estimator does not support metadata routing yet.

Parameters

ParameterType
optsobject

Returns Promise<any>

Defined in generated/feature_selection/SequentialFeatureSelector.ts:275


get_support()

get_support(opts): Promise<any>

Get a mask, or integer index, of the features selected.

Parameters

ParameterTypeDescription
optsobject-
opts.indices?booleanIf true, the return value will be an array of integers, rather than a boolean mask.

Returns Promise<any>

Defined in generated/feature_selection/SequentialFeatureSelector.ts:305


init()

init(py): Promise<void>

Initializes the underlying Python resources.

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

Parameters

ParameterType
pyPythonBridge

Returns Promise<void>

Defined in generated/feature_selection/SequentialFeatureSelector.ts:90


inverse_transform()

inverse_transform(opts): Promise<any>

Reverse the transformation operation.

Parameters

ParameterTypeDescription
optsobject-
opts.X?anyThe input samples.

Returns Promise<any>

Defined in generated/feature_selection/SequentialFeatureSelector.ts:343


set_output()

set_output(opts): Promise<any>

Set output container.

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

Parameters

ParameterTypeDescription
optsobject-
opts.transform?"default" | "pandas" | "polars"Configure output of transform and fit_transform.

Returns Promise<any>

Defined in generated/feature_selection/SequentialFeatureSelector.ts:381


transform()

transform(opts): Promise<any>

Reduce X to the selected features.

Parameters

ParameterTypeDescription
optsobject-
opts.X?anyThe input samples.

Returns Promise<any>

Defined in generated/feature_selection/SequentialFeatureSelector.ts:417