Home

Awesome

Lazy Predict

image Publish Documentation Status Downloads CodeFactor

Lazy Predict helps build a lot of basic models without much code and helps understand which models work better without any parameter tuning.

Installation

To install Lazy Predict:

pip install lazypredict

Usage

To use Lazy Predict in a project:

import lazypredict

Classification

Example:

from lazypredict.Supervised import LazyClassifier
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split

data = load_breast_cancer()
X = data.data
y = data.target

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.5, random_state=123)

clf = LazyClassifier(verbose=0, ignore_warnings=True, custom_metric=None)
models, predictions = clf.fit(X_train, X_test, y_train, y_test)

print(models)
ModelAccuracyBalanced AccuracyROC AUCF1 ScoreTime Taken
LinearSVC0.9894740.9875440.9875440.9894620.0150008
SGDClassifier0.9894740.9875440.9875440.9894620.0109992
MLPClassifier0.9859650.9869040.9869040.9859940.426
Perceptron0.9859650.9847970.9847970.9859650.0120046
LogisticRegression0.9859650.982690.982690.9859340.0200036
LogisticRegressionCV0.9859650.982690.982690.9859340.262997
SVC0.9824560.9799420.9799420.9824370.0140011
CalibratedClassifierCV0.9824560.9757280.9757280.9823570.0350015
PassiveAggressiveClassifier0.9754390.9744480.9744480.9754640.0130005
LabelPropagation0.9754390.9744480.9744480.9754640.0429988
LabelSpreading0.9754390.9744480.9744480.9754640.0310006
RandomForestClassifier0.971930.9695940.9695940.971930.033
GradientBoostingClassifier0.971930.9674860.9674860.9718690.166998
QuadraticDiscriminantAnalysis0.9649120.9662060.9662060.9650520.0119994
HistGradientBoostingClassifier0.9684210.9647390.9647390.9683870.682003
RidgeClassifierCV0.971930.9632720.9632720.9717360.0130029
RidgeClassifier0.9684210.9605250.9605250.9682420.0119977
AdaBoostClassifier0.9614040.9592450.9592450.9614440.204998
ExtraTreesClassifier0.9614040.9571380.9571380.9613620.0270066
KNeighborsClassifier0.9614040.955030.955030.9612760.0560005
BaggingClassifier0.9473680.9545770.9545770.9478820.0559971
BernoulliNB0.9508770.9510030.9510030.9510720.0169988
LinearDiscriminantAnalysis0.9614040.9508160.9508160.9610890.0199995
GaussianNB0.9543860.9495360.9495360.9543370.0139935
NuSVC0.9543860.9432150.9432150.9540140.019989
DecisionTreeClassifier0.9368420.9336930.9336930.9369710.0170023
NearestCentroid0.9473680.9335060.9335060.9468010.0160074
ExtraTreeClassifier0.9228070.9121680.9121680.9224620.0109999
CheckingClassifier0.3614040.50.50.1918790.0170043
DummyClassifier0.5122810.4895980.4895980.5189240.0119965

Regression

Example:

from lazypredict.Supervised import LazyRegressor
from sklearn import datasets
from sklearn.utils import shuffle
import numpy as np

diabetes  = datasets.load_diabetes()
X, y = shuffle(diabetes.data, diabetes.target, random_state=13)
X = X.astype(np.float32)

offset = int(X.shape[0] * 0.9)

X_train, y_train = X[:offset], y[:offset]
X_test, y_test = X[offset:], y[offset:]

reg = LazyRegressor(verbose=0, ignore_warnings=False, custom_metric=None)
models, predictions = reg.fit(X_train, X_test, y_train, y_test)

print(models)
ModelAdjusted R-SquaredR-SquaredRMSETime Taken
ExtraTreesRegressor0.3789210.52007654.22020.121466
OrthogonalMatchingPursuitCV0.3749470.51700454.39340.0111742
Lasso0.3734830.51587354.4570.00620174
LassoLars0.3734740.51586654.45750.0087235
LarsCV0.37150.51434154.54320.0160234
LassoCV0.3704130.51350154.59030.0624897
PassiveAggressiveRegressor0.3669580.51083154.73990.00689793
LassoLarsIC0.3649840.50930654.82520.0108321
SGDRegressor0.3643070.50878354.85440.0055306
RidgeCV0.3630020.50777454.91070.00728202
Ridge0.3630020.50777454.91070.00556874
BayesianRidge0.3622960.50722954.94110.0122972
LassoLarsCV0.3617490.50680654.96460.0175984
TransformedTargetRegressor0.3617490.50680654.96460.00604773
LinearRegression0.3617490.50680654.96460.00677514
Lars0.3588280.50454955.09030.00935149
ElasticNetCV0.3561590.50248655.20480.0478678
HuberRegressor0.3552510.50178555.24370.0129263
RandomForestRegressor0.3496210.49743455.48440.2331
AdaBoostRegressor0.3404160.49032255.87570.0512381
LGBMRegressor0.3392390.48941255.92550.0396187
HistGradientBoostingRegressor0.3356320.48662556.07790.0897055
PoissonRegressor0.3230330.47688956.60720.00953603
ElasticNet0.3017550.46044757.48990.00604224
KNeighborsRegressor0.2998550.45897957.56810.00757337
OrthogonalMatchingPursuit0.2924210.45323557.87290.00709486
BaggingRegressor0.2912130.45230157.92230.0302746
GradientBoostingRegressor0.2470090.41814359.70110.136803
TweedieRegressor0.2442150.41598459.81180.00633955
XGBRegressor0.2242630.40056760.59610.339694
GammaRegressor0.2238950.40028360.61050.0235181
RANSACRegressor0.2035350.3845561.40040.0653253
LinearSVR0.1167070.31745564.66070.0077076
ExtraTreeRegressor0.002019020.22883368.73040.00626636
NuSVR-0.06670430.17572871.05750.0143399
SVR-0.09641280.15277272.04020.0114729
DummyRegressor-0.297553-0.0026547878.37010.00592971
DecisionTreeRegressor-0.470263-0.13611283.42290.00749898
GaussianProcessRegressor-0.769174-0.36708991.51090.0770502
MLPRegressor-1.86772-1.21597116.5080.235267
KernelRidge-5.03822-3.6659169.0610.0243919