mlcolvar.explain.lasso.lasso_classification¶
- class mlcolvar.explain.lasso.lasso_classification(dataset, min_features=0, Cs=40, scale_inputs=True, feature_names=None, print_info=True, plot=True)[source]¶
Bases:
Perform sparse classification via LASSO on a given DictDataset (requires keys: “data” and “labels”). The (inverse) regularization strength C is automatically chosen based on cross-validation on a set of values (Cs), see sklearn.linear_model.LogisticRegressionCV. The scoring function used is SparsityScoring, balancing the accuracy and the number of features.
In the two-classes case a single classifier is built, otherwise a one-vs-rest classifier is constructed, composed by N different estimators are trained to classify each state from the others.
- Parameters:
dataset (DictDataset) – dataset with ‘data’ and ‘labels’
min_features (int, optional) – minimum number of features, by default 0
Cs (int or array-like, optional) – Each of the values in Cs describes the inverse of regularization strength. If Cs is as an int, then a grid of Cs values are chosen in a logarithmic scale between 1e-4 and 1e4. Like in support vector machines, smaller values specify stronger regularization., by default 40
scale_inputs (bool, optional) – whether to standardize inputs based on mean and std.dev., by default True
feature_names (list, optional) – names of the input features, if not given they are taken from dataset.feature_names, by default None
print_info (bool, optional) – whether to print results, by default True
plot (bool, optional) – whether to plot results, by default True
See also
mlcolvar.explain.lasso.SparsityScoringScoring function used in LASSO classification
- Returns:
classifier – optimized estimator
feats – dictionary with the names of the non-zero features, per label
coeffs – dictionary with the coefficients of the non-zero features, per label
- __init__(**kwargs)¶