hidimstat.LOCO#
- class hidimstat.LOCO(estimator, loss: callable = <function root_mean_squared_error>, method: str = 'predict', n_jobs: int = 1)[source]#
Bases:
BasePerturbation
- fit(X, y, groups=None)[source]#
Fit a model after removing each covariate/group of covariates.
- Parameters:
- Xarray-like of shape (n_samples, n_features)
The training input samples.
- yarray-like of shape (n_samples,)
The target values.
- groupsdict, default=None
A dictionary where the keys are the group names and the values are the indices of the covariates in each group.
- Returns:
- selfobject
Returns the instance itself.
- get_metadata_routing()[source]#
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)[source]#
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.
- importance(X, y)[source]#
Compute the importance scores for each group of covariates.
- Parameters:
- X: array-like of shape (n_samples, n_features)
The input samples.
- y: array-like of shape (n_samples,)
The target values.
- Returns:
- out_dict: dict
A dictionary containing the following keys: - ‘loss_reference’: the loss of the model with the original data. - ‘loss’: a dictionary containing the loss of the perturbed model for each group. - ‘importance’: the importance scores for each group.
- predict(X)[source]#
Compute the predictions after perturbation of the data for each group of variables.
- Parameters:
- X: array-like of shape (n_samples, n_features)
The input samples.
- Returns:
- out: array-like of shape (n_groups, n_permutations, n_samples)
The predictions after perturbation of the data for each group of variables.
- selection(k_best=None, percentile=None, threshold=None, threshold_pvalue=None)[source]#
Selects features based on variable importance. In case several arguments are different from None, the returned selection is the conjunction of all of them.
- Parameters:
- k_bestint, optional, default=None
Selects the top k features based on importance scores.
- percentilefloat, optional, default=None
Selects features based on a specified percentile of importance scores.
- thresholdfloat, optional, default=None
Selects features with importance scores above the specified threshold.
- threshold_pvaluefloat, optional, default=None
Selects features with p-values below the specified threshold.
- Returns:
- selectionarray-like of shape (n_features,)
Binary array indicating the selected features.
- set_fit_request(*, groups: bool | None | str = '$UNCHANGED$') LOCO [source]#
Configure whether metadata should be requested to be passed to the
fit
method.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True
(seesklearn.set_config()
). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True
: metadata is requested, and passed tofit
if provided. The request is ignored if metadata is not provided.False
: metadata is not requested and the meta-estimator will not pass it tofit
.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.
- Parameters:
- groupsstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
groups
parameter infit
.
- Returns:
- selfobject
The updated object.
- set_params(**params)[source]#
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.