The ClustersSelector class¶
Objects of this class are used to select optimal cluster expansion models, i.e. the optimal set of clusters, for given training data and clusters pool.
Initialization and methods¶
- class clusterx.clusters_selector.ClustersSelector(basis='trigonometric', selector_type='identity', **selector_opts)¶
Select optimal cluster expansion models from training data and a clusters pool.
Objects of this class select the optimal set of clusters for the given training data and clusters pool. After initializing a
ClustersSelectorobject, callClustersSelector.select_clusters()to perform the selection. Different optimality criteria can be used.- Parameters:
- basisstr, default “trigonometric”
Cluster basis used during the optimization task. For details and allowed values, see
clusterx.correlations.CorrelationsCalculator.- selector_typestr, default “identity”
Selection method:
"identity": no selection is performed. The optimal clusters pool is the same as the argumentcpoolinselect_clusters()."subsets_cv": cross-validation optimization of models defined by subsets of the clusters pool."lasso_cv": cross-validation optimization of the sparsity parameter."lasso_on_residual": LASSO selection on the residual between a model defined byset0and the output. The final model contains the union of clusters inset0and those selected by LASSO on the residual."OMP": Orthogonal Matching Pursuit.
Deprecated names are described in Notes.
- **selector_optsdict
Keyword options passed directly to the constructor. These include general options and options specific to
selector_type, described below.
- Other Parameters:
- fit_interceptbool, default True
General option controlling whether to fit an intercept.
- cv_type{“loo”, “5-fold”, “10-fold”}, default “loo”
General cross-validation option. Use
"loo"for leave-one-out CV,"5-fold"for 5-fold CV, or"10-fold"for 10-fold CV.- cv_shufflebool, default False
General option. If
cv_typeis n-fold, this specifies whether to shuffle the data for CV.- cv_random_stateint or None
General option. If
cv_shuffleisTrue, this controls the ordering of the shuffling. If None, the shuffling is different in every call. An integer gives the same shuffling for the same input, allowing reproducible results.- standardizebool, default False
General option. If
True, standardize correlations.- sparsity_maxfloat, default 1
Positive maximal sparsity parameter for
selector_type="lasso_cv".- sparsity_minfloat, default 0.01
Positive minimal sparsity parameter for
selector_type="lasso_cv".- sparsity_stepfloat, optional
Positive sparsity step for
selector_type="lasso_cv". If set to 0.0, a logarithmic grid fromsparsity_maxtosparsity_minis created automatically.- max_iterint
Maximum number of iterations for the LASSO algorithm when
selector_type="lasso_cv".- tolfloat
Small positive tolerance of the LASSO solution when
selector_type="lasso_cv".- sparsity_scale{“log”, “piece_log”}
Sparsity scale for
selector_type="lasso_cv".- clusters_sets{“size”, “combinations”, “size+combinations”}
Subset construction strategy for
selector_type="subsets_cv":"size": subpools of increasing size are extracted from the initial pool, and cross-validation selects the optimal subpool."combinations": all possible combinations of clusters from the pool are considered. This can be very computationally demanding."size+combinations": a fixed pool of clusters up to the size specified byset0is always kept. Combinations are searched only for subsets ofnclmaxclusters.
- set0array of two numbers
For
selector_type="subsets_cv"andclusters_sets="size+combinations", specifies the size of the fixed pool above which a combinatorial search is performed. The two elements[int, float]give the maximum number of cluster points and the maximum radius of the fixed subpool, respectively. This option also defines the initial model forselector_type="lasso_on_residual", as described above.- nclmaxint
For
selector_type="subsets_cv"andclusters_sets="size+combinations", the maximum number of clusters in the combinatorial subsets searched on top of the fixed subpool.- alphafloat, default 0
For subset selection, determines the regularization strength of the scikit-learn ridge estimator. If set to 0, the estimator switches to ordinary least squares.
- alphaslist or ndarray of float, default []
For subset selection, determines the list of regularization strengths. If
len(alphas) > 1, a scikit-learn RidgeCV estimator is used.- n_nonzero_coefsint, default 1
Number of nonzero parameters for
selector_type="OMP".
Notes
The deprecated selector type
"lasso"is identical to"lasso_cv"; the deprecated type"linreg"is identical to"subsets_cv". The deprecated keyword optionmethodoverridesselector_type.- display_info()¶
Display in screen information about the optimal model
- get_optimal_cpool()¶
Return optimal ClustersPool object
- get_optimal_cpool_array()¶
Return optimal array of clusters
- select_clusters(sset, cpool, prop, comat=None)¶
Select clusters
Returns a subpool containing the optimal set of clusters.
- Parameters:
- ssetStructuresSet
The structures set corresponding to the training data.
- cpoolClustersPool
the clusters pool from which the optimal model is selected.
- propstr
property label (must be in sset) of property for which the optimal set of clusters is to be selected.
- comat2D ndarray, default “None”
if the correlation matrix was precalculated, you can give it here