Class: RFECV
Recursive feature elimination with cross-validation to select features.
The number of features selected is tuned automatically by fitting an RFE
selector on the different cross-validation splits (provided by the cv
parameter). The performance of the RFE
selector are evaluated using scorer
for different number of selected features and aggregated together. Finally, the scores are averaged across folds and the number of features selected is set to the number of features that maximize the cross-validation score. See glossary entry for cross-validation estimator.
Read more in the User Guide.
Constructors
new RFECV()
new RFECV(
opts
?):RFECV
Parameters
Parameter | Type | Description |
---|---|---|
opts ? | object | - |
opts.cv ? | number | Determines the cross-validation splitting strategy. Possible inputs for cv are: |
opts.estimator ? | any | A supervised learning estimator with a fit method that provides information about feature importance either through a coef_ attribute or through a feature_importances_ attribute. |
opts.importance_getter ? | string | If ‘auto’, uses the feature importance either through a coef_ or feature_importances_ attributes of estimator. Also accepts a string that specifies an attribute name/path for extracting feature importance. 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.min_features_to_select ? | number | The minimum number of features to be selected. This number of features will always be scored, even if the difference between the original feature count and min_features_to_select isn’t divisible by step . |
opts.n_jobs ? | number | Number of cores to run in parallel while fitting across folds. undefined means 1 unless in a joblib.parallel_backend context. \-1 means using all processors. See Glossary for more details. |
opts.scoring ? | string | A string (see model evaluation documentation) or a scorer callable object / function with signature scorer(estimator, X, y) . |
opts.step ? | number | If greater than or equal to 1, then step corresponds to the (integer) number of features to remove at each iteration. If within (0.0, 1.0), then step corresponds to the percentage (rounded down) of features to remove at each iteration. Note that the last iteration may remove fewer than step features in order to reach min_features_to_select . |
opts.verbose ? | number | Controls verbosity of output. |
Returns RFECV
Defined in generated/feature_selection/RFECV.ts:25
Properties
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/feature_selection/RFECV.ts:23 |
_isInitialized | boolean | false | generated/feature_selection/RFECV.ts:22 |
_py | PythonBridge | undefined | generated/feature_selection/RFECV.ts:21 |
id | string | undefined | generated/feature_selection/RFECV.ts:18 |
opts | any | undefined | generated/feature_selection/RFECV.ts:19 |
Accessors
cv_results_
Get Signature
get cv_results_():
Promise
<any
>
All arrays (values of the dictionary) are sorted in ascending order by the number of features used (i.e., the first element of the array represents the models that used the least number of features, while the last element represents the models that used all available features). This dictionary contains the following keys:
Returns Promise
<any
>
Defined in generated/feature_selection/RFECV.ts:657
estimator_
Get Signature
get estimator_():
Promise
<any
>
The fitted estimator used to select features.
Returns Promise
<any
>
Defined in generated/feature_selection/RFECV.ts:634
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/RFECV.ts:726
n_features_
Get Signature
get n_features_():
Promise
<number
>
The number of selected features with cross-validation.
Returns Promise
<number
>
Defined in generated/feature_selection/RFECV.ts:680
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/RFECV.ts:703
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/RFECV.ts:82
ranking_
Get Signature
get ranking_():
Promise
<any
[]>
The feature ranking, such that ranking_\[i\]
corresponds to the ranking position of the i-th feature. Selected (i.e., estimated best) features are assigned rank 1.
Returns Promise
<any
[]>
Defined in generated/feature_selection/RFECV.ts:751
support_
Get Signature
get support_():
Promise
<ArrayLike
>
The mask of selected features.
Returns Promise
<ArrayLike
>
Defined in generated/feature_selection/RFECV.ts:773
Methods
decision_function()
decision_function(
opts
):Promise
<any
>
Compute the decision function of X
.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | any [] | The input samples. Internally, it will be converted to dtype=np.float32 and if a sparse matrix is provided to a sparse csr_matrix . |
Returns Promise
<any
>
Defined in generated/feature_selection/RFECV.ts:150
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/RFECV.ts:133
fit()
fit(
opts
):Promise
<any
>
Fit the RFE model and automatically tune the number of selected features.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.groups ? | ArrayLike | Group labels for the samples used while splitting the dataset into train/test set. Only used in conjunction with a “Group” cv instance (e.g., GroupKFold ). |
opts.X ? | ArrayLike | Training vector, where n_samples is the number of samples and n_features is the total number of features. |
opts.y ? | ArrayLike | Target values (integers for classification, real numbers for regression). |
Returns Promise
<any
>
Defined in generated/feature_selection/RFECV.ts:182
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/RFECV.ts:226
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/RFECV.ts:268
get_metadata_routing()
get_metadata_routing(
opts
):Promise
<any
>
Raise NotImplementedError
.
This estimator does not support metadata routing yet.
Parameters
Parameter | Type |
---|---|
opts | object |
Returns Promise
<any
>
Defined in generated/feature_selection/RFECV.ts:302
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/RFECV.ts:328
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/RFECV.ts:95
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/RFECV.ts:362
predict()
predict(
opts
):Promise
<any
>
Reduce X to the selected features and predict using the estimator.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | any | The input samples. |
Returns Promise
<any
>
Defined in generated/feature_selection/RFECV.ts:394
predict_log_proba()
predict_log_proba(
opts
):Promise
<any
[]>
Predict class log-probabilities for X.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | any | The input samples. |
Returns Promise
<any
[]>
Defined in generated/feature_selection/RFECV.ts:426
predict_proba()
predict_proba(
opts
):Promise
<any
[]>
Predict class probabilities for X.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | any [] | The input samples. Internally, it will be converted to dtype=np.float32 and if a sparse matrix is provided to a sparse csr_matrix . |
Returns Promise
<any
[]>
Defined in generated/feature_selection/RFECV.ts:458
score()
score(
opts
):Promise
<number
>
Reduce X to the selected features and return the score of the estimator.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.fit_params ? | any | Parameters to pass to the score method of the underlying estimator. |
opts.X ? | any | The input samples. |
opts.y ? | any | The target values. |
Returns Promise
<number
>
Defined in generated/feature_selection/RFECV.ts:490
set_fit_request()
set_fit_request(
opts
):Promise
<any
>
Request metadata passed to the fit
method.
Note that this method is only relevant if enable_metadata_routing=True
(see sklearn.set_config
). Please see User Guide on how the routing mechanism works.
The options for each parameter are:
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.groups ? | string | boolean | Metadata routing for groups parameter in fit . |
Returns Promise
<any
>
Defined in generated/feature_selection/RFECV.ts:536
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/RFECV.ts:570
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/RFECV.ts:602