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 (opens in a new tab)
Constructors
constructor()
Signature
new SequentialFeatureSelector(opts?: object): SequentialFeatureSelector;
Parameters
Name | Type | Description |
---|---|---|
opts? | object | - |
opts.cv? | number | Determines the cross-validation splitting strategy. Possible inputs for cv are: |
opts.direction? | "forward" | "backward" | Whether to perform forward selection or backward selection. Default Value 'forward' |
opts.estimator? | any | An unfitted estimator. |
opts.n_features_to_select? | number | "auto" | If "auto" , the behaviour depends on the tol parameter: Default Value 'auto' |
opts.n_jobs? | number | Number 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 (opens in a new tab) context. \-1 means using all processors. See Glossary for more details. |
opts.scoring? | string | A 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? | number | If 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" . 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
Defined in: generated/feature_selection/SequentialFeatureSelector.ts:25 (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/feature_selection/SequentialFeatureSelector.ts:140 (opens in a new tab)
fit()
Learn the features to select from X.
Signature
fit(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | Training vectors, where n\_samples is the number of samples and n\_features is the number of predictors. |
opts.y? | ArrayLike | Target values. This parameter may be ignored for unsupervised learning. |
Returns
Promise
<any
>
Defined in: generated/feature_selection/SequentialFeatureSelector.ts:157 (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
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike [] | Input samples. |
opts.fit_params? | any | Additional fit parameters. |
opts.y? | ArrayLike | Target values (undefined for unsupervised transformations). |
Returns
Promise
<any
[]>
Defined in: generated/feature_selection/SequentialFeatureSelector.ts:201 (opens in a new tab)
get_feature_names_out()
Mask feature names according to selected features.
Signature
get_feature_names_out(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.input_features? | any | Input features. |
Returns
Promise
<any
>
Defined in: generated/feature_selection/SequentialFeatureSelector.ts:253 (opens in a new tab)
get_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
Signature
get_metadata_routing(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.routing? | any | A MetadataRequest encapsulating routing information. |
Returns
Promise
<any
>
Defined in: generated/feature_selection/SequentialFeatureSelector.ts:293 (opens in a new tab)
get_support()
Get a mask, or integer index, of the features selected.
Signature
get_support(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.indices? | boolean | If true , the return value will be an array of integers, rather than a boolean mask. Default Value false |
Returns
Promise
<any
>
Defined in: generated/feature_selection/SequentialFeatureSelector.ts:331 (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
Name | Type |
---|---|
py | PythonBridge |
Returns
Promise
<void
>
Defined in: generated/feature_selection/SequentialFeatureSelector.ts:90 (opens in a new tab)
inverse_transform()
Reverse the transformation operation.
Signature
inverse_transform(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | any | The input samples. |
Returns
Promise
<any
>
Defined in: generated/feature_selection/SequentialFeatureSelector.ts:370 (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
Name | Type | Description |
---|---|---|
opts | object | - |
opts.transform? | "default" | "pandas" | Configure output of transform and fit\_transform . |
Returns
Promise
<any
>
Defined in: generated/feature_selection/SequentialFeatureSelector.ts:410 (opens in a new tab)
transform()
Reduce X to the selected features.
Signature
transform(opts: object): Promise<any>;
Parameters
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | any | The input samples. |
Returns
Promise
<any
>
Defined in: generated/feature_selection/SequentialFeatureSelector.ts:448 (opens in a new tab)
Properties
_isDisposed
boolean
=false
Defined in: generated/feature_selection/SequentialFeatureSelector.ts:23 (opens in a new tab)
_isInitialized
boolean
=false
Defined in: generated/feature_selection/SequentialFeatureSelector.ts:22 (opens in a new tab)
_py
PythonBridge
Defined in: generated/feature_selection/SequentialFeatureSelector.ts:21 (opens in a new tab)
id
string
Defined in: generated/feature_selection/SequentialFeatureSelector.ts:18 (opens in a new tab)
opts
any
Defined in: generated/feature_selection/SequentialFeatureSelector.ts:19 (opens in a new tab)
Accessors
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/feature_selection/SequentialFeatureSelector.ts:513 (opens in a new tab)
n_features_in_
Number of features seen during fit. Only defined if the underlying estimator exposes such an attribute when fit.
Signature
n_features_in_(): Promise<number>;
Returns
Promise
<number
>
Defined in: generated/feature_selection/SequentialFeatureSelector.ts:486 (opens in a new tab)
n_features_to_select_
The number of features that were selected.
Signature
n_features_to_select_(): Promise<number>;
Returns
Promise
<number
>
Defined in: generated/feature_selection/SequentialFeatureSelector.ts:540 (opens in a new tab)
py
Signature
py(): PythonBridge;
Returns
PythonBridge
Defined in: generated/feature_selection/SequentialFeatureSelector.ts:77 (opens in a new tab)
Signature
py(pythonBridge: PythonBridge): void;
Parameters
Name | Type |
---|---|
pythonBridge | PythonBridge |
Returns
void
Defined in: generated/feature_selection/SequentialFeatureSelector.ts:81 (opens in a new tab)
support_
The mask of selected features.
Signature
support_(): Promise<ArrayLike>;
Returns
Promise
<ArrayLike
>
Defined in: generated/feature_selection/SequentialFeatureSelector.ts:567 (opens in a new tab)