The EstimatorFactory class

Objects of this class are used to generate estimators, either from scikit-learn or native from CELL

Initialization and methods

class clusterx.estimators.estimator_factory.EstimatorFactory

Property-estimator factory

static create(estimator_type, **estimator_opts)

Create an estimator object from (or compatible with) the scikit-learn library.

Parameters:

estimator_type: string

If the string starts with "skl_", and the full string is "skl_EstimatorName", then an instance of the "EstimatorName" estimator of the scikit-learn library is created.

estimator_opts: dictionary

The estimator "EstimatorName" is initialized with the parameters given by the dictionary estimator_opts

Examples:

In both examples below, X is the input matrix, y is the vector of property values, and X0 is the input vector for a sample for which we want to predict the property value.

The precise meaning and the complete list of parameters in the estimator_opts dictionary is to be taken from the documentation for the input parameters of the corresponding sklearn class (see example links below).

Create a linear regression estimator object from the scikit-learn class sklearn.linear_model.LinearRegression:

from clusterx.estimator_factory import EstimatorFactory

linreg = EstimatorFactory.create("skl_LinearRegression", {"fit_intercept": True})

linreg.fit(X,y)

prediction0 = linreg.predict(X0)
...

Create a LASSO estimator object from the scikit-learn class sklearn.linear_model.Lasso:

from clusterx.estimator_factory import EstimatorFactory

lasso = EstimatorFactory.create("skl_Lasso", {"fit_intercept": True, "alpha": 0.1})

lasso.fit(X,y)

prediction0 = lasso.predict(X0)
...