adelie.sklearn.CSSModelSelection#

class adelie.sklearn.CSSModelSelection(alpha: float, n_inits: int = 1, n_sims: int = 10000, n_threads: int = 1, seed: int | None = None)[source]#

Column Subset Selection estimator for model selection with scikit-learn compatible API.

The finite-sample guaranteed test procedure for Gaussian features is run to identify the smallest subset that most likely reconstructs the rest of the features based on the subset factor loss and swapping method.

Parameters:
alphafloat

Nominal level for the test.

n_initsint, optional

Number of random initializations. Default is 1.

n_simsint, optional

Number of Monte Carlo samples to estimate critical thresholds. Default is int(1e4).

n_threadsint, optional

Number of threads. Default is 1.

seedint, optional

Random seed. If None, no particular seed is used. Default is None.

Methods

__init__(alpha[, n_inits, n_sims, ...])

Initialize the CSS estimator.

fit(X[, y])

Fit the CSS model under subset factor loss and perform model selection.

fit_cov(S, n)

Fit the CSS model under subset factor loss and perform model selection.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

score(X[, y, sample_weight])

Compute the (negative) subset factor loss.

set_params(**params)

Set the parameters of this estimator.

set_score_request(*[, sample_weight])

Request metadata passed to the score method.

__init__(alpha: float, n_inits: int = 1, n_sims: int = 10000, n_threads: int = 1, seed: int | None = None)[source]#

Initialize the CSS estimator.

fit(X: ndarray, y: ndarray | None = None)[source]#

Fit the CSS model under subset factor loss and perform model selection.

Parameters:
X(n, p) ndarray

Feature matrix.

y(n,) ndarray, optional

Not used and only present here for API consistency by convention. Default is None.

Returns:
self

Returns an instance of self.

See also

fit_cov()
fit_cov(S: ndarray, n: int)[source]#

Fit the CSS model under subset factor loss and perform model selection.

Parameters:
S(p, p) ndarray

Positive semi-definite matrix \(\Sigma\).

nint

Number of samples.

Returns:
self

Returns an instance of self.

get_metadata_routing()#

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:
routingMetadataRequest

A MetadataRequest encapsulating routing information.

get_params(deep=True)#

Get parameters for this estimator.

Parameters:
deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:
paramsdict

Parameter names mapped to their values.

score(X: ndarray, y: ndarray | None = None, sample_weight: ndarray | None = None)[source]#

Compute the (negative) subset factor loss.

Parameters:
X(n, p) ndarray

Feature matrix.

y(n,) ndarray, optional

Not used and only present here for API consistency by convention. Default is None.

sample_weights(n,) ndarray, optional

Not used and only present here for API consistency by convention. Default is None.

Returns:
lossfloat

Subset factor loss where \(T\) is given by the fitted subset.

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:
**paramsdict

Estimator parameters.

Returns:
selfestimator instance

Estimator instance.

set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') CSSModelSelection#

Request metadata passed to the score 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:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters:
sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_weight parameter in score.

Returns:
selfobject

The updated object.