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_typestr
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_optsdict
The estimator
"EstimatorName"is initialized with the parameters given by the dictionaryestimator_opts
Examples
In both examples below,
Xis the input matrix,yis the vector of property values, andX0is 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_optsdictionary 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) ...