Updated Code #342
talk2sunil83
started this conversation in
Ideas
Replies: 1 comment
-
Could you check this one out? https://github.com/nityansuman/lazypredict-nightly |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi There,
I have latest sklearn (ubuntu 20) as of now and made some changes in Supervised.py (Till line # 78) and its working for me. If you feel to incorporate. please do it.
Note: original code is commented in each previous line
"""
Supervised Models
"""
Author: Shankar Rao Pandala [email protected]
import numpy as np
import pandas as pd
from tqdm import tqdm
import datetime
import time
import sklearn
from sklearn.pipeline import Pipeline
from sklearn.impute import SimpleImputer, MissingIndicator
from sklearn.preprocessing import StandardScaler, OneHotEncoder
from sklearn.compose import ColumnTransformer
from sklearn.utils.testing import all_estimators
from sklearn.utils import all_estimators
from sklearn.base import RegressorMixin
from sklearn.base import ClassifierMixin
from sklearn.metrics import accuracy_score, balanced_accuracy_score, roc_auc_score, f1_score, r2_score, mean_squared_error
import warnings
import xgboost
import catboost
import lightgbm
warnings.filterwarnings("ignore")
pd.set_option("display.precision", 2)
pd.set_option("display.float_format", lambda x: '%.2f' % x)
CLASSIFIERS = [est for est in all_estimators(
) if issubclass(est[1], ClassifierMixin)]
REGRESSORS = [est for est in all_estimators(
) if issubclass(est[1], RegressorMixin)]
removed_classifiers = [('ClassifierChain', sklearn.multioutput.ClassifierChain),
('ComplementNB', sklearn.naive_bayes.ComplementNB),
('GradientBoostingClassifier',
# sklearn.ensemble.gradient_boosting.GradientBoostingClassifier),
sklearn.ensemble.GradientBoostingClassifier),
# ('GaussianProcessClassifier', sklearn.gaussian_process.gpc.GaussianProcessClassifier),
('GaussianProcessClassifier', sklearn.gaussian_process.GaussianProcessClassifier),
('HistGradientBoostingClassifier',
sklearn.ensemble._hist_gradient_boosting.gradient_boosting.HistGradientBoostingClassifier),
# ('MLPClassifier', sklearn.neural_network.multilayer_perceptron.MLPClassifier),
('MLPClassifier', sklearn.neural_network.MLPClassifier),
# ('LogisticRegressionCV', sklearn.linear_model.logistic.LogisticRegressionCV),
('LogisticRegressionCV', sklearn.linear_model.LogisticRegressionCV),
('MultiOutputClassifier', sklearn.multioutput.MultiOutputClassifier),
('MultinomialNB', sklearn.naive_bayes.MultinomialNB),
('OneVsOneClassifier', sklearn.multiclass.OneVsOneClassifier),
('OneVsRestClassifier', sklearn.multiclass.OneVsRestClassifier),
('OutputCodeClassifier', sklearn.multiclass.OutputCodeClassifier),
('RadiusNeighborsClassifier',
# sklearn.neighbors.classification.RadiusNeighborsClassifier),
sklearn.neighbors.RadiusNeighborsClassifier),
# ('VotingClassifier', sklearn.ensemble.voting.VotingClassifier)]
('VotingClassifier', sklearn.ensemble.VotingClassifier)]
removed_regressors = [('TheilSenRegressor', sklearn.linear_model.theil_sen.TheilSenRegressor),
removed_regressors = [('TheilSenRegressor', sklearn.linear_model.TheilSenRegressor),
('ARDRegression', sklearn.linear_model.ARDRegression),
('CCA', sklearn.cross_decomposition.CCA),
('IsotonicRegression', sklearn.isotonic.IsotonicRegression),
('MultiOutputRegressor', sklearn.multioutput.MultiOutputRegressor),
('MultiTaskElasticNet',
sklearn.linear_model.MultiTaskElasticNet),
('MultiTaskElasticNetCV',
sklearn.linear_model.MultiTaskElasticNetCV),
('MultiTaskLasso', sklearn.linear_model.MultiTaskLasso),
('MultiTaskLassoCV',
sklearn.linear_model.MultiTaskLassoCV),
('PLSCanonical', sklearn.cross_decomposition.PLSCanonical),
('PLSRegression', sklearn.cross_decomposition.PLSRegression),
('RadiusNeighborsRegressor',
sklearn.neighbors.RadiusNeighborsRegressor),
('RegressorChain', sklearn.multioutput.RegressorChain),
('VotingRegressor', sklearn.ensemble.VotingRegressor),
# ('_SigmoidCalibration', sklearn.calibration._SigmoidCalibration)
]
for i in removed_regressors:
REGRESSORS.pop(REGRESSORS.index(i))
for i in removed_classifiers:
CLASSIFIERS.pop(CLASSIFIERS.index(i))
REGRESSORS.append(('XGBRegressor', xgboost.XGBRegressor))
REGRESSORS.append(('LGBMRegressor', lightgbm.LGBMRegressor))
REGRESSORS.append(('CatBoostRegressor',catboost.CatBoostRegressor))
CLASSIFIERS.append(('XGBClassifier', xgboost.XGBClassifier))
CLASSIFIERS.append(('LGBMClassifier', lightgbm.LGBMClassifier))
CLASSIFIERS.append(('CatBoostClassifier',catboost.CatBoostClassifier))
numeric_transformer = Pipeline(steps=[
('imputer', SimpleImputer(strategy='mean')),
('scaler', StandardScaler())
])
categorical_transformer = Pipeline(steps=[
('imputer', SimpleImputer(strategy='constant', fill_value='missing')),
('encoding', OneHotEncoder(handle_unknown='ignore', sparse=False))
])
Helper class for performing classification
class LazyClassifier:
"""
This module helps in fitting to all the classification algorithms that are available in Scikit-learn
Parameters
----------
verbose : int, optional (default=0)
For the liblinear and lbfgs solvers set verbose to any positive
number for verbosity.
ignore_warnings : bool, optional (default=True)
When set to True, the warning related to algorigms that are not able to run are ignored.
custom_metric : function, optional (default=None)
When function is provided, models are evaluated based on the custom evaluation metric provided.
prediction : bool, optional (default=False)
When set to True, the predictions of all the models models are returned as dataframe.
Helper class for performing classification
class LazyRegressor:
"""
This module helps in fitting regression models that are available in Scikit-learn
Parameters
----------
verbose : int, optional (default=0)
For the liblinear and lbfgs solvers set verbose to any positive
number for verbosity.
ignore_warnings : bool, optional (default=True)
When set to True, the warning related to algorigms that are not able to run are ignored.
custom_metric : function, optional (default=None)
When function is provided, models are evaluated based on the custom evaluation metric provided.
prediction : bool, optional (default=False)
When set to True, the predictions of all the models models are returned as dataframe.
Regression = LazyRegressor
Classification = LazyClassifier
Beta Was this translation helpful? Give feedback.
All reactions