Documentation
Classes
SelectFromModel

SelectFromModel

Meta-transformer for selecting features based on importance weights.

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new SelectFromModel(opts?: object): SelectFromModel;

Parameters

NameTypeDescription
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. Default Value 'auto'
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. Default Value 1
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. Default Value false
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 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/feature_selection/SelectFromModel.ts:19 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/feature_selection/SelectFromModel.ts:18 (opens in a new tab)

_py

PythonBridge

Defined in: generated/feature_selection/SelectFromModel.ts:17 (opens in a new tab)

id

string

Defined in: generated/feature_selection/SelectFromModel.ts:14 (opens in a new tab)

opts

any

Defined in: generated/feature_selection/SelectFromModel.ts:15 (opens in a new tab)

Accessors

estimator_

The base estimator from which the transformer is built. This attribute exist only when fit has been called.

Signature

estimator_(): Promise<any>;

Returns

Promise<any>

Defined in: generated/feature_selection/SelectFromModel.ts:457 (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/feature_selection/SelectFromModel.ts:507 (opens in a new tab)

max_features_

Maximum number of features calculated during fit. Only defined if the max\_features is not undefined.

Signature

max_features_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/feature_selection/SelectFromModel.ts:482 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/feature_selection/SelectFromModel.ts:66 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/feature_selection/SelectFromModel.ts:70 (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/SelectFromModel.ts:123 (opens in a new tab)

fit()

Fit the SelectFromModel meta-transformer.

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]The training input samples.
opts.fit_params?anyOther estimator specific parameters.
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:140 (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/feature_selection/SelectFromModel.ts:189 (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

NameTypeDescription
optsobject-
opts.input_features?anyInput features.

Returns

Promise<any>

Defined in: generated/feature_selection/SelectFromModel.ts:236 (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

NameTypeDescription
optsobject-
opts.indices?booleanIf 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/SelectFromModel.ts:272 (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/feature_selection/SelectFromModel.ts:79 (opens in a new tab)

inverse_transform()

Reverse the transformation operation.

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.X?anyThe input samples.

Returns

Promise<any>

Defined in: generated/feature_selection/SelectFromModel.ts:307 (opens in a new tab)

partial_fit()

Fit the SelectFromModel meta-transformer only once.

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]The training input samples.
opts.fit_params?anyOther estimator specific parameters.
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:342 (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/feature_selection/SelectFromModel.ts:391 (opens in a new tab)

transform()

Reduce X to the selected features.

Signature

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

Parameters

NameTypeDescription
optsobject-
opts.X?anyThe input samples.

Returns

Promise<any>

Defined in: generated/feature_selection/SelectFromModel.ts:424 (opens in a new tab)