Class: SelectFromModel
Meta-transformer for selecting features based on importance weights.
Constructors
new SelectFromModel()
new SelectFromModel(
opts
?):SelectFromModel
Parameters
Parameter | Type | Description |
---|---|---|
opts ? | object | - |
opts.estimator ? | any | The base estimator from which the transformer is built. This can be both a fitted (if prefit is set to true ) or a non-fitted estimator. The estimator should have a feature_importances_ or coef_ attribute after fitting. Otherwise, the importance_getter parameter should be used. |
opts.importance_getter ? | string | If ‘auto’, uses the feature importance either through a coef_ attribute or feature_importances_ attribute of estimator. Also accepts a string that specifies an attribute name/path for extracting feature importance (implemented with attrgetter ). For example, give regressor_.coef_ in case of TransformedTargetRegressor or named_steps.clf.feature_importances_ in case of Pipeline with its last step named clf . If callable , overrides the default feature importance getter. The callable is passed with the fitted estimator and it should return importance for each feature. |
opts.max_features ? | number | The maximum number of features to select. |
opts.norm_order ? | any | Order of the norm used to filter the vectors of coefficients below threshold in the case where the coef_ attribute of the estimator is of dimension 2. |
opts.prefit ? | boolean | Whether a prefit model is expected to be passed into the constructor directly or not. If true , estimator must be a fitted estimator. If false , estimator is fitted and updated by calling fit and partial_fit , respectively. |
opts.threshold ? | string | number | The threshold value to use for feature selection. Features whose absolute importance value is greater or equal are kept while the others are discarded. If “median” (resp. “mean”), then the threshold value is the median (resp. the mean) of the feature importances. A scaling factor (e.g., “1.25*mean”) may also be used. If undefined and if the estimator has a parameter penalty set to l1, either explicitly or implicitly (e.g, Lasso), the threshold used is 1e-5. Otherwise, “mean” is used by default. |
Returns SelectFromModel
Defined in generated/feature_selection/SelectFromModel.ts:21
Properties
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/feature_selection/SelectFromModel.ts:19 |
_isInitialized | boolean | false | generated/feature_selection/SelectFromModel.ts:18 |
_py | PythonBridge | undefined | generated/feature_selection/SelectFromModel.ts:17 |
id | string | undefined | generated/feature_selection/SelectFromModel.ts:14 |
opts | any | undefined | generated/feature_selection/SelectFromModel.ts:15 |
Accessors
estimator_
Get Signature
get estimator_():
Promise
<any
>
The base estimator from which the transformer is built. This attribute exist only when fit
has been called.
Returns Promise
<any
>
Defined in generated/feature_selection/SelectFromModel.ts:467
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/SelectFromModel.ts:517
max_features_
Get Signature
get max_features_():
Promise
<number
>
Maximum number of features calculated during fit. Only defined if the max_features
is not undefined
.
Returns Promise
<number
>
Defined in generated/feature_selection/SelectFromModel.ts:492
py
Get Signature
get py():
PythonBridge
Returns PythonBridge
Set Signature
set py(
pythonBridge
):void
Parameters
Parameter | Type |
---|---|
pythonBridge | PythonBridge |
Returns void
Defined in generated/feature_selection/SelectFromModel.ts:66
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/SelectFromModel.ts:118
fit()
fit(
opts
):Promise
<any
>
Fit the SelectFromModel meta-transformer.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.fit_params ? | any | If enable_metadata_routing=False (default): |
opts.X ? | ArrayLike [] | The training input samples. |
opts.y ? | ArrayLike | The target values (integers that correspond to classes in classification, real numbers in regression). |
Returns Promise
<any
>
Defined in generated/feature_selection/SelectFromModel.ts:135
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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.fit_params ? | any | Additional fit parameters. |
opts.X ? | ArrayLike [] | Input samples. |
opts.y ? | ArrayLike | Target values (undefined for unsupervised transformations). |
Returns Promise
<any
[]>
Defined in generated/feature_selection/SelectFromModel.ts:179
get_feature_names_out()
get_feature_names_out(
opts
):Promise
<any
>
Mask feature names according to selected features.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.input_features ? | any | Input features. |
Returns Promise
<any
>
Defined in generated/feature_selection/SelectFromModel.ts:221
get_metadata_routing()
get_metadata_routing(
opts
):Promise
<any
>
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.routing ? | any | A MetadataRouter encapsulating routing information. |
Returns Promise
<any
>
Defined in generated/feature_selection/SelectFromModel.ts:257
get_support()
get_support(
opts
):Promise
<any
>
Get a mask, or integer index, of the features selected.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.indices ? | boolean | If true , the return value will be an array of integers, rather than a boolean mask. |
Returns Promise
<any
>
Defined in generated/feature_selection/SelectFromModel.ts:291
init()
init(
py
):Promise
<void
>
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
Parameters
Parameter | Type |
---|---|
py | PythonBridge |
Returns Promise
<void
>
Defined in generated/feature_selection/SelectFromModel.ts:79
inverse_transform()
inverse_transform(
opts
):Promise
<any
>
Reverse the transformation operation.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | any | The input samples. |
Returns Promise
<any
>
Defined in generated/feature_selection/SelectFromModel.ts:325
partial_fit()
partial_fit(
opts
):Promise
<any
>
Fit the SelectFromModel meta-transformer only once.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.partial_fit_params ? | any | If enable_metadata_routing=False (default): |
opts.X ? | ArrayLike [] | The training input samples. |
opts.y ? | ArrayLike | The target values (integers that correspond to classes in classification, real numbers in regression). |
Returns Promise
<any
>
Defined in generated/feature_selection/SelectFromModel.ts:359
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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.transform ? | "default" | "pandas" | "polars" | Configure output of transform and fit_transform . |
Returns Promise
<any
>
Defined in generated/feature_selection/SelectFromModel.ts:403
transform()
transform(
opts
):Promise
<any
>
Reduce X to the selected features.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | any | The input samples. |
Returns Promise
<any
>
Defined in generated/feature_selection/SelectFromModel.ts:435