LazyFastCan#

class fastcan.LazyFastCan(n_features_to_select=1, feature_generator=None, sample_mask=None, tol=1e-10)#

Lazy version of FastCan selector.

Added in version 0.5.1.

Parameters:
  • n_features_to_select (int, default=1) – The parameter is the absolute number of features to select.

  • feature_generator (callable or None, default=None) – A generator that takes the input data X and an array of skip_indices and yields (index, feature) tuples, where index should be from 0 to n_features-1. The skip_indices indicates which features should be skipped. If the generator requires additional parameters, you can use functools.partial to wrap the generator with those parameters.

  • sample_mask (ndarray of shape (n_samples,), default=None) – Bool mask for valid samples.

  • tol (float, default=1e-10) – Tolerance for linear dependence check. The classical Gram-Schmidt fails when abs(x.T @ W) > tol.

indices_#

The indices of the selected features. The order of the indices is corresponding to the feature selection process.

Type:

ndarray of shape (n_features_to_select,), dtype=int

scores_#

The h-correlation scores of selected features. The order of the scores is corresponding to the feature selection process.

Type:

ndarray of shape (n_features_to_select,), dtype=float

Examples

>>> from functools import partial
>>> from fastcan import LazyFastCan
>>> from fastcan.narx import gen_time_shift_features, make_time_shift_ids
>>> fg = partial(gen_time_shift_features, ids=make_time_shift_ids(2, 2))
>>> X = [[1, 2], [3, 4], [5, 6], [7, 8]]
>>> y = [[0, 0], [0, 1], [1, 1], [0, 2]]
>>> LazyFastCan(2, feature_generator=fg).fit(X, y).indices_
array([2, 1])
get_metadata_routing()#

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:

routing – A MetadataRequest encapsulating routing information.

Return type:

MetadataRequest

get_params(deep=True)#

Get parameters for this estimator.

Parameters:

deep (bool, default=True) – If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:

params – Parameter names mapped to their values.

Return type:

dict

set_params(**params)#

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:

**params (dict) – Estimator parameters.

Returns:

self – Estimator instance.

Return type:

estimator instance