The Model class

Objects of this class comprise represent a cluster expansion model

Initialization and methods

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

Model class

Parameters:

corrc: CorrelationsCalculator object

The correlations calculator corresponding to the optimal model.

property_name: String

The methods of the Model class that take a StructureSet object as argument, will query property values named according to property_name.

estimator: Estimator object

An estimator object to predict the property values. Alternatively, The effective cluster interactions (ECIs) can be set.

ecis: Array of float

Effective cluster iteractions (multiplied by the corresponding multiplicities). Overrides estimator object.

filepath: string (default: None)

Overrides all the above. Used to initialize from file. Path of a json or pickle file containing a serialized Model object, as generated by the Model.serialize() method.

json_db_filepath: string (default: None)

DEPRECATED, use filepath instead. Overrides all the above. Used to initialize from file. Path of a json file containing a serialized Model object, as generated by the Model.serialize() method.

get_all_errors(sset, srtd=False)

Return absolute errors of every structure in a structures set.

Parameters:

sset: StructuresSet object

the errors are calculated for every structure in the structures set

srtd: Boolean (default: False)

if True the output errors are sorted from smallest to largest.

Returns: structured numpy array with fields:

[('index','<i4'), ('error','<f4')]

i.e., every element of the array contains a tuple with an integer, the structure index and a float, the absolute error

get_correlations_calculator()

Return correlations calculator of the Model object

get_cv_score(sset, fit_params=None)

Get leave-one-out cross-validation score over structures set.

Parameters:

fit_params: dictionary

Parameters to pass to the fit method of the estimator.

get_ecis()

Return array of effective cluster interactions (ECIs) of the model

get_errors(sset)

Compute RMSE, MAE and MaxAE for model in structures set.

get_parent_lattice()

Return parent lattice of the cluster expansion model.

predict(structure)

Predict property with the optimal cluster expansion model.

Parameters:

structure: Structure object

structure object to calculate property to.

predict_swap(structure, ind1=None, ind2=None, correlation=False, site_types=[0])

Predict property difference with the optimal cluster expansion model.

Parameters:

structure: Structure object

structure object to calculate property difference to.

ind1: int

index of first atom position has been swapped

ind2: int

index of second atom position has been swapped

report_errors(sset)

Report fit and CV scores

Parameters:

sset: StructuresSet object

the scores are computed for the give structures set

serialize(filepath=None, fmt=None, db_name=None)

Write cluster expansion model to Json database

Parameter:

filepath: string

Name of the file to store the Model instance. It can contain the relative or absolute path. If not given, and if db_name (deprecated) is None, filepathh is set to “cemodel.pickle” and fmt is overriden (set to pickle).

fmt: string

It can take the values "pickle" or "json". So far, object can only be re-initiated from a "pickle" file, therefore this is the preferred format. If not given, it is inferred from the filepathh.

db_name: (DEPRECATED) string

Name of the json file containing the database