Skip to content

Commit e346657

Browse files
Merge pull request #316 from brendalf/feat/ajusted_rsquared
[docs] Update LazyRegressor examples to include Adjusted R Square
2 parents 1299a5f + 52ebe1e commit e346657

File tree

2 files changed

+106
-91
lines changed

2 files changed

+106
-91
lines changed

README.rst

Lines changed: 56 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Lazy Predict
2020
.. image:: https://www.codefactor.io/repository/github/shankarpandala/lazypredict/badge
2121
:target: https://www.codefactor.io/repository/github/shankarpandala/lazypredict
2222
:alt: CodeFactor
23-
23+
2424
Lazy Predict helps build a lot of basic models without much code and helps understand which models works better without any parameter tuning.
2525

2626

@@ -52,16 +52,16 @@ Example ::
5252
from lazypredict.Supervised import LazyClassifier
5353
from sklearn.datasets import load_breast_cancer
5454
from sklearn.model_selection import train_test_split
55-
55+
5656
data = load_breast_cancer()
5757
X = data.data
5858
y= data.target
59-
59+
6060
X_train, X_test, y_train, y_test = train_test_split(X, y,test_size=.5,random_state =123)
61-
61+
6262
clf = LazyClassifier(verbose=0,ignore_warnings=True, custom_metric=None)
6363
models,predictions = clf.fit(X_train, X_test, y_train, y_test)
64-
64+
6565
print(models)
6666

6767

@@ -108,60 +108,66 @@ Example ::
108108
from sklearn import datasets
109109
from sklearn.utils import shuffle
110110
import numpy as np
111-
111+
112112
boston = datasets.load_boston()
113113
X, y = shuffle(boston.data, boston.target, random_state=13)
114114
X = X.astype(np.float32)
115-
115+
116116
offset = int(X.shape[0] * 0.9)
117-
117+
118118
X_train, y_train = X[:offset], y[:offset]
119119
X_test, y_test = X[offset:], y[offset:]
120-
121-
reg = LazyRegressor(verbose=0,ignore_warnings=False, custom_metric=None)
122-
models,predictions = reg.fit(X_train, X_test, y_train, y_test)
123-
120+
121+
reg = LazyRegressor(verbose=0, ignore_warnings=False, custom_metric=None)
122+
models, predictions = reg.fit(X_train, X_test, y_train, y_test)
123+
124124
print(models)
125125

126126

127-
| Model | R-Squared | RMSE | Time Taken |
128-
|:------------------------------|------------:|---------:|-------------:|
129-
| SVR | 0.877199 | 2.62054 | 0.0330021 |
130-
| RandomForestRegressor | 0.874429 | 2.64993 | 0.0659981 |
131-
| ExtraTreesRegressor | 0.867566 | 2.72138 | 0.0570002 |
132-
| AdaBoostRegressor | 0.865851 | 2.73895 | 0.144999 |
133-
| NuSVR | 0.863712 | 2.7607 | 0.0340044 |
134-
| GradientBoostingRegressor | 0.858693 | 2.81107 | 0.13 |
135-
| KNeighborsRegressor | 0.826307 | 3.1166 | 0.0179954 |
136-
| HistGradientBoostingRegressor | 0.810479 | 3.25551 | 0.820995 |
137-
| BaggingRegressor | 0.800056 | 3.34383 | 0.0579946 |
138-
| MLPRegressor | 0.750536 | 3.73503 | 0.725997 |
139-
| HuberRegressor | 0.736973 | 3.83522 | 0.0370018 |
140-
| LinearSVR | 0.71914 | 3.9631 | 0.0179989 |
141-
| RidgeCV | 0.718402 | 3.9683 | 0.018003 |
142-
| BayesianRidge | 0.718102 | 3.97041 | 0.0159984 |
143-
| Ridge | 0.71765 | 3.9736 | 0.0149941 |
144-
| LinearRegression | 0.71753 | 3.97444 | 0.0190051 |
145-
| TransformedTargetRegressor | 0.71753 | 3.97444 | 0.012001 |
146-
| LassoCV | 0.717337 | 3.9758 | 0.0960066 |
147-
| ElasticNetCV | 0.717104 | 3.97744 | 0.0860076 |
148-
| LassoLarsCV | 0.717045 | 3.97786 | 0.0490005 |
149-
| LassoLarsIC | 0.716636 | 3.98073 | 0.0210001 |
150-
| LarsCV | 0.715031 | 3.99199 | 0.0450008 |
151-
| Lars | 0.715031 | 3.99199 | 0.0269964 |
152-
| SGDRegressor | 0.714362 | 3.99667 | 0.0210009 |
153-
| RANSACRegressor | 0.707849 | 4.04198 | 0.111998 |
154-
| ElasticNet | 0.690408 | 4.16088 | 0.0190012 |
155-
| Lasso | 0.662141 | 4.34668 | 0.0180018 |
156-
| OrthogonalMatchingPursuitCV | 0.591632 | 4.77877 | 0.0180008 |
157-
| ExtraTreeRegressor | 0.583314 | 4.82719 | 0.0129974 |
158-
| PassiveAggressiveRegressor | 0.556668 | 4.97914 | 0.0150032 |
159-
| GaussianProcessRegressor | 0.428298 | 5.65425 | 0.0580051 |
160-
| OrthogonalMatchingPursuit | 0.379295 | 5.89159 | 0.0180039 |
161-
| DecisionTreeRegressor | 0.318767 | 6.17217 | 0.0230272 |
162-
| DummyRegressor | -0.0215752 | 7.55832 | 0.0140116 |
163-
| LassoLars | -0.0215752 | 7.55832 | 0.0180008 |
164-
| KernelRidge | -8.24669 | 22.7396 | 0.0309792 |
127+
| Model | Adjusted R-Squared | R-Squared | RMSE | Time Taken |
128+
|:------------------------------|-------------------:|----------:|------:|-----------:|
129+
| SVR | 0.83 | 0.88 | 2.62 | 0.01 |
130+
| BaggingRegressor | 0.83 | 0.88 | 2.63 | 0.03 |
131+
| NuSVR | 0.82 | 0.86 | 2.76 | 0.03 |
132+
| RandomForestRegressor | 0.81 | 0.86 | 2.78 | 0.21 |
133+
| XGBRegressor | 0.81 | 0.86 | 2.79 | 0.06 |
134+
| GradientBoostingRegressor | 0.81 | 0.86 | 2.84 | 0.11 |
135+
| ExtraTreesRegressor | 0.79 | 0.84 | 2.98 | 0.12 |
136+
| AdaBoostRegressor | 0.78 | 0.83 | 3.04 | 0.07 |
137+
| HistGradientBoostingRegressor | 0.77 | 0.83 | 3.06 | 0.17 |
138+
| PoissonRegressor | 0.77 | 0.83 | 3.11 | 0.01 |
139+
| LGBMRegressor | 0.77 | 0.83 | 3.11 | 0.07 |
140+
| KNeighborsRegressor | 0.77 | 0.83 | 3.12 | 0.01 |
141+
| DecisionTreeRegressor | 0.65 | 0.74 | 3.79 | 0.01 |
142+
| MLPRegressor | 0.65 | 0.74 | 3.80 | 1.63 |
143+
| HuberRegressor | 0.64 | 0.74 | 3.84 | 0.01 |
144+
| GammaRegressor | 0.64 | 0.73 | 3.88 | 0.01 |
145+
| LinearSVR | 0.62 | 0.72 | 3.96 | 0.01 |
146+
| RidgeCV | 0.62 | 0.72 | 3.97 | 0.01 |
147+
| BayesianRidge | 0.62 | 0.72 | 3.97 | 0.01 |
148+
| Ridge | 0.62 | 0.72 | 3.97 | 0.01 |
149+
| TransformedTargetRegressor | 0.62 | 0.72 | 3.97 | 0.01 |
150+
| LinearRegression | 0.62 | 0.72 | 3.97 | 0.01 |
151+
| ElasticNetCV | 0.62 | 0.72 | 3.98 | 0.04 |
152+
| LassoCV | 0.62 | 0.72 | 3.98 | 0.06 |
153+
| LassoLarsIC | 0.62 | 0.72 | 3.98 | 0.01 |
154+
| LassoLarsCV | 0.62 | 0.72 | 3.98 | 0.02 |
155+
| Lars | 0.61 | 0.72 | 3.99 | 0.01 |
156+
| LarsCV | 0.61 | 0.71 | 4.02 | 0.04 |
157+
| SGDRegressor | 0.60 | 0.70 | 4.07 | 0.01 |
158+
| TweedieRegressor | 0.59 | 0.70 | 4.12 | 0.01 |
159+
| GeneralizedLinearRegressor | 0.59 | 0.70 | 4.12 | 0.01 |
160+
| ElasticNet | 0.58 | 0.69 | 4.16 | 0.01 |
161+
| Lasso | 0.54 | 0.66 | 4.35 | 0.02 |
162+
| RANSACRegressor | 0.53 | 0.65 | 4.41 | 0.04 |
163+
| OrthogonalMatchingPursuitCV | 0.45 | 0.59 | 4.78 | 0.02 |
164+
| PassiveAggressiveRegressor | 0.37 | 0.54 | 5.09 | 0.01 |
165+
| GaussianProcessRegressor | 0.23 | 0.43 | 5.65 | 0.03 |
166+
| OrthogonalMatchingPursuit | 0.16 | 0.38 | 5.89 | 0.01 |
167+
| ExtraTreeRegressor | 0.08 | 0.32 | 6.17 | 0.01 |
168+
| DummyRegressor | -0.38 | -0.02 | 7.56 | 0.01 |
169+
| LassoLars | -0.38 | -0.02 | 7.56 | 0.01 |
170+
| KernelRidge | -11.50 | -8.25 | 22.74 | 0.01 |
165171

166172

167173
.. warning::

lazypredict/Supervised.py

Lines changed: 50 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -436,54 +436,63 @@ class LazyRegressor:
436436
>>> from sklearn import datasets
437437
>>> from sklearn.utils import shuffle
438438
>>> import numpy as np
439+
439440
>>> boston = datasets.load_boston()
440441
>>> X, y = shuffle(boston.data, boston.target, random_state=13)
441442
>>> X = X.astype(np.float32)
443+
442444
>>> offset = int(X.shape[0] * 0.9)
443445
>>> X_train, y_train = X[:offset], y[:offset]
444446
>>> X_test, y_test = X[offset:], y[offset:]
445-
>>> reg = LazyRegressor(verbose=0,ignore_warnings=False, custom_metric=None )
446-
>>> models,predictions = reg.fit(X_train, X_test, y_train, y_test)
447-
>>> model_dictionary = reg.provide_models(X_train,X_test,y_train,y_test)
447+
448+
>>> reg = LazyRegressor(verbose=0, ignore_warnings=False, custom_metric=None)
449+
>>> models, predictions = reg.fit(X_train, X_test, y_train, y_test)
450+
>>> model_dictionary = reg.provide_models(X_train, X_test, y_train, y_test)
448451
>>> models
449-
| Model | R-Squared | RMSE | Time Taken |
450-
|:------------------------------|------------:|---------:|-------------:|
451-
| SVR | 0.877199 | 2.62054 | 0.0330021 |
452-
| RandomForestRegressor | 0.874429 | 2.64993 | 0.0659981 |
453-
| ExtraTreesRegressor | 0.867566 | 2.72138 | 0.0570002 |
454-
| AdaBoostRegressor | 0.865851 | 2.73895 | 0.144999 |
455-
| NuSVR | 0.863712 | 2.7607 | 0.0340044 |
456-
| GradientBoostingRegressor | 0.858693 | 2.81107 | 0.13 |
457-
| KNeighborsRegressor | 0.826307 | 3.1166 | 0.0179954 |
458-
| HistGradientBoostingRegressor | 0.810479 | 3.25551 | 0.820995 |
459-
| BaggingRegressor | 0.800056 | 3.34383 | 0.0579946 |
460-
| MLPRegressor | 0.750536 | 3.73503 | 0.725997 |
461-
| HuberRegressor | 0.736973 | 3.83522 | 0.0370018 |
462-
| LinearSVR | 0.71914 | 3.9631 | 0.0179989 |
463-
| RidgeCV | 0.718402 | 3.9683 | 0.018003 |
464-
| BayesianRidge | 0.718102 | 3.97041 | 0.0159984 |
465-
| Ridge | 0.71765 | 3.9736 | 0.0149941 |
466-
| LinearRegression | 0.71753 | 3.97444 | 0.0190051 |
467-
| TransformedTargetRegressor | 0.71753 | 3.97444 | 0.012001 |
468-
| LassoCV | 0.717337 | 3.9758 | 0.0960066 |
469-
| ElasticNetCV | 0.717104 | 3.97744 | 0.0860076 |
470-
| LassoLarsCV | 0.717045 | 3.97786 | 0.0490005 |
471-
| LassoLarsIC | 0.716636 | 3.98073 | 0.0210001 |
472-
| LarsCV | 0.715031 | 3.99199 | 0.0450008 |
473-
| Lars | 0.715031 | 3.99199 | 0.0269964 |
474-
| SGDRegressor | 0.714362 | 3.99667 | 0.0210009 |
475-
| RANSACRegressor | 0.707849 | 4.04198 | 0.111998 |
476-
| ElasticNet | 0.690408 | 4.16088 | 0.0190012 |
477-
| Lasso | 0.662141 | 4.34668 | 0.0180018 |
478-
| OrthogonalMatchingPursuitCV | 0.591632 | 4.77877 | 0.0180008 |
479-
| ExtraTreeRegressor | 0.583314 | 4.82719 | 0.0129974 |
480-
| PassiveAggressiveRegressor | 0.556668 | 4.97914 | 0.0150032 |
481-
| GaussianProcessRegressor | 0.428298 | 5.65425 | 0.0580051 |
482-
| OrthogonalMatchingPursuit | 0.379295 | 5.89159 | 0.0180039 |
483-
| DecisionTreeRegressor | 0.318767 | 6.17217 | 0.0230272 |
484-
| DummyRegressor | -0.0215752 | 7.55832 | 0.0140116 |
485-
| LassoLars | -0.0215752 | 7.55832 | 0.0180008 |
486-
| KernelRidge | -8.24669 | 22.7396 | 0.0309792 |
452+
| Model | Adjusted R-Squared | R-Squared | RMSE | Time Taken |
453+
|:------------------------------|-------------------:|----------:|------:|-----------:|
454+
| SVR | 0.83 | 0.88 | 2.62 | 0.01 |
455+
| BaggingRegressor | 0.83 | 0.88 | 2.63 | 0.03 |
456+
| NuSVR | 0.82 | 0.86 | 2.76 | 0.03 |
457+
| RandomForestRegressor | 0.81 | 0.86 | 2.78 | 0.21 |
458+
| XGBRegressor | 0.81 | 0.86 | 2.79 | 0.06 |
459+
| GradientBoostingRegressor | 0.81 | 0.86 | 2.84 | 0.11 |
460+
| ExtraTreesRegressor | 0.79 | 0.84 | 2.98 | 0.12 |
461+
| AdaBoostRegressor | 0.78 | 0.83 | 3.04 | 0.07 |
462+
| HistGradientBoostingRegressor | 0.77 | 0.83 | 3.06 | 0.17 |
463+
| PoissonRegressor | 0.77 | 0.83 | 3.11 | 0.01 |
464+
| LGBMRegressor | 0.77 | 0.83 | 3.11 | 0.07 |
465+
| KNeighborsRegressor | 0.77 | 0.83 | 3.12 | 0.01 |
466+
| DecisionTreeRegressor | 0.65 | 0.74 | 3.79 | 0.01 |
467+
| MLPRegressor | 0.65 | 0.74 | 3.80 | 1.63 |
468+
| HuberRegressor | 0.64 | 0.74 | 3.84 | 0.01 |
469+
| GammaRegressor | 0.64 | 0.73 | 3.88 | 0.01 |
470+
| LinearSVR | 0.62 | 0.72 | 3.96 | 0.01 |
471+
| RidgeCV | 0.62 | 0.72 | 3.97 | 0.01 |
472+
| BayesianRidge | 0.62 | 0.72 | 3.97 | 0.01 |
473+
| Ridge | 0.62 | 0.72 | 3.97 | 0.01 |
474+
| TransformedTargetRegressor | 0.62 | 0.72 | 3.97 | 0.01 |
475+
| LinearRegression | 0.62 | 0.72 | 3.97 | 0.01 |
476+
| ElasticNetCV | 0.62 | 0.72 | 3.98 | 0.04 |
477+
| LassoCV | 0.62 | 0.72 | 3.98 | 0.06 |
478+
| LassoLarsIC | 0.62 | 0.72 | 3.98 | 0.01 |
479+
| LassoLarsCV | 0.62 | 0.72 | 3.98 | 0.02 |
480+
| Lars | 0.61 | 0.72 | 3.99 | 0.01 |
481+
| LarsCV | 0.61 | 0.71 | 4.02 | 0.04 |
482+
| SGDRegressor | 0.60 | 0.70 | 4.07 | 0.01 |
483+
| TweedieRegressor | 0.59 | 0.70 | 4.12 | 0.01 |
484+
| GeneralizedLinearRegressor | 0.59 | 0.70 | 4.12 | 0.01 |
485+
| ElasticNet | 0.58 | 0.69 | 4.16 | 0.01 |
486+
| Lasso | 0.54 | 0.66 | 4.35 | 0.02 |
487+
| RANSACRegressor | 0.53 | 0.65 | 4.41 | 0.04 |
488+
| OrthogonalMatchingPursuitCV | 0.45 | 0.59 | 4.78 | 0.02 |
489+
| PassiveAggressiveRegressor | 0.37 | 0.54 | 5.09 | 0.01 |
490+
| GaussianProcessRegressor | 0.23 | 0.43 | 5.65 | 0.03 |
491+
| OrthogonalMatchingPursuit | 0.16 | 0.38 | 5.89 | 0.01 |
492+
| ExtraTreeRegressor | 0.08 | 0.32 | 6.17 | 0.01 |
493+
| DummyRegressor | -0.38 | -0.02 | 7.56 | 0.01 |
494+
| LassoLars | -0.38 | -0.02 | 7.56 | 0.01 |
495+
| KernelRidge | -11.50 | -8.25 | 22.74 | 0.01 |
487496
"""
488497

489498
def __init__(

0 commit comments

Comments
 (0)