Semi-AutoML — Lazy Predict. Guide to find the best ML algorithms in just 2 lines of code.
Hi there………… how’re things going on! been a while….. today I got again something really cool for you. Using the function we can easily sort out the best-fit algorithms from the list of more than 500 algorithms.
Shall we get started?
LONG STORY SHORT
QUICK ~ Install the package using
pip install lazypredict
Now if you get any errors while installing the package probably will be the package compatibility. OLD VERSIONS VS NEW VERSIONS…. ufff ya always hate that part. No worries do a clean installation using a different environment ‘env’ …
Let’s perform what I promised
For Classification Problems
#classification
from lazypredict.Supervised import LazyClassifier
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
#dummy dataset
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=.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)
Wa la! done…………..
Let’s do the same for regression.
For Regression Problems
#Regression
from lazypredict.Supervised import LazyRegressor
from sklearn import datasets
from sklearn.utils import shuffle
import numpy as np
#Dummy Dataset
boston = datasets.load_boston()
X, y = shuffle(boston.data, boston.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)
print(predictions)
Cool! isn’t it? ……….I hope you enjoyed it.. see you soon with another cool topic.
If you like to know more about advanced topics like clustering follow my other article A-Z Clustering
Some of my alternative internet presences are Facebook, Instagram, Udemy, Blogger, Issuu, and more.
Also available on Quora @ https://www.quora.com/profile/Bob-Rupak-Roy
Comments
Post a Comment