The ModelBuilder class

Objects of this class act as Model factories

Initialization and methods

class clusterx.model.ModelBuilder(*args, **kwargs)

Model class

Objects of this class represent a cluster expansion model.

Parameters:
basisstr, default “trigonometric”

Basis set used to calculate the matrix of cluster correlations. For a detailed description and possible values of this parameter, look at the documentation for parameter basis in CorrelationsCalculator

selector_typestr

Cluster selector type. For the possible values, look at the documentation for the parameter selector_type in the ClustersSelector class.

selector_optsdict

Cluster selector options. For the possible values, look at the documentation for the parameter selector_opts in the ClustersSelector class.

estimator_typestr

Estimator type. For the possible values, look at the documentation for the parameter estimator_type in the EstimatorFactory class.

estimator_optsdict

Estimator options. For the possible values, look at the documentation for the parameter estimator_opts in the EstimatorFactory class.

filepathstr, default None

If not None, it must be the path to a pickle file generated with ModelBuilder.serialize(). All other parameters are overriden

standardizebool (defaut:False)

Whether to standardize the input. Uses StandardScaler of scikit-learn.

build(sset: StructuresSet, cpool: ClustersPool, prop: str | List[str], corrc: CorrelationsCalculator | None = None, verbose: bool = False, **kwargs)

Build optimal cluster expansion model

Acts as a Model factory.

Parameters:
ssetStructuresSet

structures set used for model training.

cpoolClustersPool

clusters pool from which to select the best model using the method indicated in selector_type.

propstr or list of str

Property name or list of property names. Must be a valid name as stored in sset. The list of names can be obtained using sset.get_property_names().

corrcCorrelationsCalculator, default None

If not None, cpool and basis are overriden

**kwargsdict

Keyword arguments passed to the fit method of the estimator.

get_estimator()

Return estimator object used to create the optimal model

get_initial_comat()

Return initial correlation matrix

Return the initial correlation matrix, i.e. the full correlation matrix before cluster selection is performed.

get_opt_cpool()

Return optimal clusters pool found in build.

When the build method is called, a ClustersSelector object is created to perform the cluster selection task. The selected clusters pool can be obtained by calling this function.

get_selector()

Return selector used in build.

When the build method is called, a ClustersSelector object is created to perform the cluster selection task. This selector can be obtained by calling this function.

serialize(filepath='MODELBDR.pickle')

Serialize model into pickle file

Only pickle format is supported.

Parameters:
filepathstr, default “MODELBDR.pickle”

file path of the pickle file to serialize the model builder object