Omics Diary
Published in

Omics Diary

How to use the Lazy Predict library to select the best machine learning model

Using the best machine learning tools to answer the right questions

pip install lazypredict
conda install -c conda-forge xgboost
conda install -c conda-forge lightgbm
%matplotlib inlineimport numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import as px
from IPython.display import display
df =
from pandas.plotting import scatter_matrix
attributes = ["sepal_length", "sepal_width", "petal_length", "petal_width"]
scatter_matrix(df[attributes], figsize = (10,8))
df_cat_to_array = pd.get_dummies(df)
df_cat_to_array = df_cat_to_array.drop("species_id", axis=1)
import lazypredict
from sklearn.model_selection import train_test_split
from lazypredict.Supervised import LazyRegressor
X = df_cat_to_array .drop(["sepal_width"], axis=1)Y = df_cat_to_array ["sepal_width"]X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size = 0.2, random_state = 64)reg = LazyRegressor(verbose=0, ignore_warnings=False, custom_metric=None)models,pred =, X_test, y_train, y_test)models
from lazypredict.Supervised import LazyClassifier
from sklearn.model_selection import train_test_split
X =  df_cat_to_array.drop(["species_setosa", "species_versicolor", "species_virginica"], axis=1)Y = df_cat_to_array["species_versicolor"]X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size=0.2, random_state =55)clf = LazyClassifier(verbose=0, ignore_warnings=True, custom_metric=None)models,predictions =, X_test, y_train, y_test)models



A platform to share knowledge and information on how to use Python for systems vaccinology and omics analysis. Also covers interesting scientific literature related to infectious diseases and vaccines. Interested in contributing? Contact me to collaborate!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kuan Rong Chan, Ph.D.

Kuan Rong Chan, PhD, Principal Research Scientist in Duke-NUS Medical School. Virologist | Data Scientist | Loves mahjong | Website: