Python-Libraries

less than 1 minute read

Published:

This post covers Introduction to some other python libraries.

Black

pip install black

black sample_code.py
black folder_name/

LazyPredict

Classification

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=.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)

Regression

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

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)

Lux

pip install lux-api

jupyter labextension install @jupyter-widgets/jupyterlab-manager

jupyter labextension install luxwidget
import lux
import pandas as pd

file = "https://raw.githubusercontent.com/lux-org/lux-datasets/master/data/college.csv"
df = pd.read_csv(file)
df
df.intent = ["AverageCost","SATAverage"]
df
from lux.vis.Vis import Vis
Vis(["Region=New England","MedianEarnings"], df)
from lux.vis.VisList import VisList
VisList(["Region=?","AverageCost"], df)