DocumentationClassesSelectFromModel

Class: SelectFromModel

Meta-transformer for selecting features based on importance weights.

Python Reference

Constructors

new SelectFromModel()

new SelectFromModel(opts?): SelectFromModel

Parameters

ParameterTypeDescription
opts?object-
opts.estimator?anyThe 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?stringIf ‘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?numberThe maximum number of features to select.
opts.norm_order?anyOrder 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?booleanWhether 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 | numberThe 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

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/feature_selection/SelectFromModel.ts:19
_isInitializedbooleanfalsegenerated/feature_selection/SelectFromModel.ts:18
_pyPythonBridgeundefinedgenerated/feature_selection/SelectFromModel.ts:17
idstringundefinedgenerated/feature_selection/SelectFromModel.ts:14
optsanyundefinedgenerated/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

ParameterType
pythonBridgePythonBridge

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

ParameterTypeDescription
optsobject-
opts.fit_params?anyIf enable_metadata_routing=False (default):
opts.X?ArrayLike[]The training input samples.
opts.y?ArrayLikeThe 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

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/SelectFromModel.ts:179


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/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

ParameterTypeDescription
optsobject-
opts.routing?anyA 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

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/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

ParameterType
pyPythonBridge

Returns Promise<void>

Defined in generated/feature_selection/SelectFromModel.ts:79


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/SelectFromModel.ts:325


partial_fit()

partial_fit(opts): Promise<any>

Fit the SelectFromModel meta-transformer only once.

Parameters

ParameterTypeDescription
optsobject-
opts.partial_fit_params?anyIf enable_metadata_routing=False (default):
opts.X?ArrayLike[]The training input samples.
opts.y?ArrayLikeThe 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

ParameterTypeDescription
optsobject-
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

ParameterTypeDescription
optsobject-
opts.X?anyThe input samples.

Returns Promise<any>

Defined in generated/feature_selection/SelectFromModel.ts:435