Regressors

_DEFAULT_REGRESSORS

A private dictionary containing the classes of the default regressors that EasyFit provides in EasyRegressor.

The table contains the keys of the dictionary to access the models, and links to the documentation of each model.

Regressor (Dict Key)

Class (Dict Value)

DummyRegressor

sklearn.dummy.DummyRegressor

LinearRegressor

sklearn.linear_model.LinearRegression

LassoRegressor

sklearn.linear_model.Lasso

RidgeRegressor

sklearn.linear_model.Ridge

BayesianRidgeRegressor

sklearn.linear_model.BayesianRidge

ElasticNetRegressor

sklearn.linear_model.ElasticNet

SGDRegressor

sklearn.linear_model.SGDRegressor

DecisionTreeRegressor

sklearn.tree.DecisionTreeRegressor

GaussianProcessRegressor

sklearn.gaussian_process.GaussianProcessRegressor

SupportVectorRegressor

sklearn.svm.SVR

LinearSVR

sklearn.svm.LinearSVR

XGBRegressor

xgboost.sklearn.XGBRegressor

XGBRFRegressor

xgboost.sklearn.XGBRFRegressor

MLPRegressor

sklearn.neural_network.MLPRegressor

easyfit.regressors module

class easyfit.regressors.EasyRegressor(*args, **kwargs)[source]

Bases: _EasyModel

Fit regressor models in
  • _DEFAULT_REGRESSORS (if include_defaults=True)

  • models_dict (if models_dict != None)

Parameters:
  • models_dict (Dictionary of additional models) –

    Can hold:
    • classes: models_dict = {‘LinearRegression’: LinearRegression}

    • objects: models_dict = {‘LinearRegression’: LinearRegression()}

    (Default value = None)

  • include_defaults (boolean) –

    Include _DEFAULT_REGRESSORS in trained models

    (Default value = True)

evaluate(X, y, as_df=True, model_first=True, from_preds=False)[source]

Returns models results on each of the metrics in self._METRICS dictionary

Parameters:
  • X (array of features) –

  • y (array of targets) –

  • as_df (boolean) –

    • if True: return results in pd.DataFrame

    • if False: return results in dictionary

    (Default value = True)

  • model_first (boolean) –

    • if True: returns models at axis=0 (rows), results at axis=1 (columns)

    • if False: returns models at axis=1 (columns), results at axis=0 (rows)

    (Default value = True)

  • from_preds (boolean) –

    • if True: make preditions then calacuate metrics (X holds input features)

    • if False: calcualte metrics from predictions (X holds predictions)

    (Default value = True)

Returns:

results

Return type:

Dict (as_df=False) or pd.Dataframe (as_df=True)

fit(X, y)[source]

Fit regressors in self._models on features X with targets y

Calls method fit for each model in self._models

Parameters:
  • X (array of features) –

  • y (array of targets) –

Return type:

None

get_model(model_key)[source]

Get specific model from self._models

Parameters:

model_key (the key for model in self._models) –

Returns:

  • model object corrseponding to key if key exist

  • None if key does not exist

predict(X)[source]

Make predictions for features in X

Call predict method for each model in self._models

Parameters:

X (array of features) –

Returns:

preds – Dictionary with same keys in self._models and predictions for each model of features in X

Return type:

Dict

score(X, y, as_df=True, sort=True)[source]

Calculate score for each model in self._models

Calls score method for each model in self._models

Return mean accuracy for each model on the given data and labels

Parameters:
  • X (array of features) –

  • y (array of targets) –

  • as_df (boolean) –

    • if True: return results in pd.DataFrame

    • if False: return results in dictionary

    (Default value = True)

  • sort (boolean) –

    • if True: returns results sorted in discending order by score

    • if False: returns results in the original order of models

    (Default value = True)

Returns:

results

Return type:

Dict (as_df=False) or pd.Dataframe (as_df=True)