Package: modelLab
modelLabis a comprehensive library of machine learning models
designed to facilitate regression or classification tasks on a given
dataset. It encompasses a diverse range of models and provides a
comprehensive evaluation of each model’s performance, delivering a
comprehensive set of metrics in a Python dictionary.PURPOSE OF THE PACKAGEThe primary objective of the package is to offer a curated ensemble
of renowned scikit-learn models, enabling users to conveniently train
all models with a single function call.FEATURESCollections of Machine learning modelsClassification Models‘LinearSVC’‘SGDClassifier’‘MLPClassifier’‘Perceptron’‘LogisticRegression’‘LogisticRegressionCV’‘SVC’‘CalibratedClassifierCV’‘PassiveAggressiveClassifier’‘LabelPropagation’‘LabelSpreading’‘RandomForestClassifier’‘GradientBoostingClassifier’‘QuadraticDiscriminantAnalysis’‘HistGradientBoostingClassifier’‘RidgeClassifierCV’‘RidgeClassifier’‘AdaBoostClassifier’‘ExtraTreesClassifier’‘KNeighborsClassifier’‘BaggingClassifier’‘BernoulliNB’‘LinearDiscriminantAnalysis’‘GaussianNB’‘NuSVC’‘DecisionTreeClassifier’‘NearestCentroid’‘ExtraTreeClassifier’‘DummyClassifier’Regression Models‘SVR’‘RandomForestRegressor’‘ExtraTreesRegressor’‘AdaBoostRegressor’‘NuSVR’‘GradientBoostingRegressor’‘KNeighborsRegressor’‘HuberRegressor’‘RidgeCV’‘BayesianRidge’‘Ridge’‘LinearRegression’‘LarsCV’‘MLPRegressor’‘XGBRegressor’‘CatBoostRegressor’‘LGBMRegressor’Can also be used for the custom models.GETTING STARTEDThis package is available on PyPI, allowing for convenient installation through the PyPI repository.Dependencies-  'scikit-learn'
-  'xgboost'
-  'catboost'
-  'lightgbm'INSTALLATIONIf you already installed scikit-learn, the easiest way to install
modelLab is usingpip:pipinstallmodelLabUSAGE>>>frommodelLabimportregressors,classifier>>>regressors(X,y,models=models,verbose=False,rets=True)#X,y is data>>>classifier(X,y,models=models,verbose=False,rets=True)ExamplesRegression Problem>>>frommodelLabimportregressors>>>fromsklearn.datasetsimportfetch_california_housing>>>X,y=fetch_california_housing(return_X_y=True)>>>regressors(X,y,verbose=True)Model:SVRAdjustedR^2:-0.0249R^2:-0.0229MSE:1.3768RMSE:1.1734MAE:0.8698Model:RandomForestRegressorAdjustedR^2:0.8034R^2:0.8038MSE:0.2641RMSE:0.5139MAE:0.3364Model:ExtraTreesRegressorAdjustedR^2:0.8102R^2:0.8105MSE:0.2550RMSE:0.5050MAE:0.3333Model:AdaBoostRegressorAdjustedR^2:0.4563R^2:0.4574MSE:0.7304RMSE:0.8546MAE:0.7296Model:NuSVRAdjustedR^2:0.0069R^2:0.0088MSE:1.3342RMSE:1.1551MAE:0.8803Model:GradientBoostingRegressorAdjustedR^2:0.7753R^2:0.7757MSE:0.3019RMSE:0.5494MAE:0.3789Model:KNeighborsRegressorAdjustedR^2:0.1435R^2:0.1451MSE:1.1506RMSE:1.0727MAE:0.8183Model:HuberRegressorAdjustedR^2:0.3702R^2:0.3714MSE:0.8461RMSE:0.9198MAE:0.5800Model:RidgeCVAdjustedR^2:0.5868R^2:0.5876MSE:0.5551RMSE:0.7450MAE:0.5423Model:BayesianRidgeAdjustedR^2:0.5868R^2:0.5876MSE:0.5551RMSE:0.7451MAE:0.5422Model:RidgeAdjustedR^2:0.5867R^2:0.5875MSE:0.5552RMSE:0.7451MAE:0.5422Model:LinearRegressionAdjustedR^2:0.5867R^2:0.5875MSE:0.5552RMSE:0.7451MAE:0.5422Model:LarsCVAdjustedR^2:0.5211R^2:0.5220MSE:0.6433RMSE:0.8021MAE:0.5524Model:MLPRegressorAdjustedR^2:-3.5120R^2:-3.5032MSE:6.0613RMSE:2.4620MAE:1.7951Model:XGBRegressorAdjustedR^2:0.8269R^2:0.8272MSE:0.2326RMSE:0.4822MAE:0.3195Model:CatBoostRegressorAdjustedR^2:0.8461R^2:0.8464MSE:0.2068RMSE:0.4547MAE:0.3005Model:LGBMRegressorAdjustedR^2:0.8319R^2:0.8322MSE:0.2259RMSE:0.4753MAE:0.3185Classification Problem>>>frommodelLabimportregressors,classifier>>>fromsklearn.datasetsimportload_iris>>>X,y=load_iris(return_X_y=True)>>>importwarnings>>>warnings.filterwarnings('ignore')>>>classifier(X,y,verbose=True)Model:LinearSVCAccuracy:0.9667Precision:0.9694Recall:0.9667F1Score:0.9667Model:SGDClassifierAccuracy:0.9667Precision:0.9694Recall:0.9667F1Score:0.9661Model:MLPClassifierAccuracy:1.0000Precision:1.0000Recall:1.0000F1Score:1.0000Model:PerceptronAccuracy:0.8667Precision:0.9022Recall:0.8667F1Score:0.8626Model:LogisticRegressionAccuracy:0.9667Precision:0.9694Recall:0.9667F1Score:0.9667Model:SVCAccuracy:0.9667Precision:0.9694Recall:0.9667F1Score:0.9667Model:CalibratedClassifierCVAccuracy:0.9667Precision:0.9694Recall:0.9667F1Score:0.9667Model:PassiveAggressiveClassifierAccuracy:0.9667Precision:0.9694Recall:0.9667F1Score:0.9667Model:LabelPropagationAccuracy:0.9667Precision:0.9694Recall:0.9667F1Score:0.9667Model:LabelSpreadingAccuracy:0.9667Precision:0.9694Recall:0.9667F1Score:0.9667Model:RandomForestClassifierAccuracy:0.9667Precision:0.9694Recall:0.9667F1Score:0.9667Model:GradientBoostingClassifierAccuracy:0.9333Precision:0.9436Recall:0.9333F1Score:0.9331Model:QuadraticDiscriminantAnalysisAccuracy:1.0000Precision:1.0000Recall:1.0000F1Score:1.0000Model:HistGradientBoostingClassifierAccuracy:0.9000Precision:0.9214Recall:0.9000F1Score:0.8989Model:RidgeClassifierCVAccuracy:0.8667Precision:0.8754Recall:0.8667F1Score:0.8662Model:RidgeClassifierAccuracy:0.8667Precision:0.8754Recall:0.8667F1Score:0.8662Model:AdaBoostClassifierAccuracy:0.9333Precision:0.9436Recall:0.9333F1Score:0.9331Model:ExtraTreesClassifierAccuracy:0.9667Precision:0.9694Recall:0.9667F1Score:0.9667Model:KNeighborsClassifierAccuracy:0.9667Precision:0.9694Recall:0.9667F1Score:0.9667Model:BaggingClassifierAccuracy:0.9333Precision:0.9436Recall:0.9333F1Score:0.9331Model:BernoulliNBAccuracy:0.2333Precision:0.0544Recall:0.2333F1Score:0.0883Model:LinearDiscriminantAnalysisAccuracy:1.0000Precision:1.0000Recall:1.0000F1Score:1.0000Model:GaussianNBAccuracy:0.9333Precision:0.9333Recall:0.9333F1Score:0.9333Model:NuSVCAccuracy:0.9667Precision:0.9694Recall:0.9667F1Score:0.9667Model:DecisionTreeClassifierAccuracy:0.9333Precision:0.9436Recall:0.9333F1Score:0.9331Model:NearestCentroidAccuracy:0.9000Precision:0.9025Recall:0.9000F1Score:0.9000Model:ExtraTreeClassifierAccuracy:0.9667Precision:0.9694Recall:0.9667F1Score:0.9667Model:DummyClassifierAccuracy:0.2333Precision:0.0544Recall:0.2333F1Score:0.0883Using Custom Models>>>fromsklearn.datasetsimportmake_regression>>>fromsklearn.linear_modelimportLinearRegression>>>frommodelLabimportregressors>>>X,y=make_regression(n_samples=100,n_features=10,random_state=42)>>>models={'Linear Regression':LinearRegression()}>>>regressors(X,y,models=models,verbose=False,rets=True)defaultdict(<class'dict'>, {'LinearRegression': {'AdjustedR^2': 1.0, 'R^2': 1.0, 'MSE': 3.097635893749451e-26, 'RMSE': 1.7600101970583725e-13, 'MAE': 1.4992451724538115e-13}})>>>fromsklearn.datasetsimportmake_regression,make_classification>>>fromsklearn.linear_modelimportLogisticRegression>>>frommodelLabimportclassifier>>>X,y=make_classification(n_samples=100,n_features=10,random_state=42)>>>models={'Logistic Regression':LogisticRegression()}>>>classifier(X,y,models=models,verbose=False,rets=True)defaultdict(<class'dict'>, {'LogisticRegression': {'Accuracy': 0.95, 'Precision': 0.9545454545454545, 'Recall': 0.95, 'F1Score': 0.949874686716792}})Contributor and Author[Abhishek Kaddipudi]MailLinkedinGitHub