LAZYPREDICT - INTRO AND ERROR
- Naina Pandey
- May 19, 2023
- 3 min read

I am writing this article to help all the newbies like me to understand this awesome package and one little error which is faced by many of my peers which unfortunately made them turn their back towards this literal lifesaver package.
So most people find it baffling to select a model which will work most efficiently on their dataset. Thanks to Shankar Pandala who came up with this package. This helps us find a Supervised algorithm that is best suited for our data and help you save a lot of time. If you are like me, then you must be writing code for at least 4 or 5 models before you decide which of them gives you the highest accuracy. Sounds very cumbersome, isn’t it? Lazy Predict helps you in saving time and energy which you can use somewhere else.
LazyPredict builds the basic models with no parameter tuning at all. The given output shows you all the basic models along with their results and time, which helps you to choose the most optimal model. After that, you can go ahead and do parameter tuning or you can choose the top 5 models and make an ensemble model with them. So, let us see how can we implement the LazyPredict and during this, we will also solve the error in dependencies that we will encounter en route.
Installation
1. Use pip to install the Lazypredict.
!pip install LazyPredict
2. Now import LazyPredict
import LazyPredict
3. We have options on both the Supervised Regression algorithms and Supervised Classifiers as well. (In the case of Classifier, just put LazyClassifier instead of LazyRegressor) from LazyPredict.Supervised import LazyRegressor
4. After loading and splitting your data into training and testing, we will create an object of LazyRegressor
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=.5, random_state =123)
LR = LazyRegressor(verbose=0, ignore_warnings=True, custom_metric = None)
5. After this we will fit our data into the model and check the output
### fitting data in LazyClassifier
models,predictions = LR.fit(X_train, X_test, y_train, y_test)
### lets check which model did better on Breast Cancer Dataset
print(models)
6. Now here you can get two things first is output which will look something like this:

second, you can get an error that will look something like this:

Let us first understand why we got this terrible error. the current version of lazypredict requires that you use the scikit-learn==0.23.1 because a couple of things have changed after the scikit-learn upgrade to version 0.24. We need to update the lazypredict support of scikit-learn.
In case, you are not able to update the Lazypredict( I tried it wasn’t getting updated if you can please comment below and let me know). The issues exist in Supervised.py, where many dependencies are not working or written according to the old version. Many changes needed to be done to make this thing work. I had Notepad++ with me so it was easy peasy for me to edit Supervised.py according to the sklearn documentation. I am going to leave that updated file here…
This package was a time saver for me cause it helped me to find out the best suitable supervised models for both regression and classification. I do hope this will help you to select the best model rather than giving up on this package. You can use google colab to run this as it takes a lot of computational power.
I hope this will help you and help me spread the word about this package. You won’t regret it..:)
Comments