%load_ext autoreload
%autoreload 2
%matplotlib inline
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = [14, 9]
from sklearn.datasets import make_classification
from sklearn.linear_model import LogisticRegression
from sklearn.ensemble import GradientBoostingClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
X, y = make_classification(n_samples=10000, n_informative=5, random_state=0)
X_train, X_test, y_train, y_test = train_test_split(X, y)
lr = LogisticRegression(solver='lbfgs', max_iter=1000)
gbc = GradientBoostingClassifier()
rfc = RandomForestClassifier(n_estimators=100)
lr.fit(X_train, y_train)
gbc.fit(X_train, y_train)
rfc.fit(X_train, y_train)
RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini', max_depth=None, max_features='auto', max_leaf_nodes=None, min_impurity_decrease=0.0, min_impurity_split=None, min_samples_leaf=1, min_samples_split=2, min_weight_fraction_leaf=0.0, n_estimators=100, n_jobs=None, oob_score=False, random_state=None, verbose=0, warm_start=False)
from sklearn_plot_api import plot_roc_curve
viz_lr = plot_roc_curve(lr, X, y)
viz_lr.line_.set_color('red')
viz_lr.figure_
fig, ax = plt.subplots()
viz_lr = plot_roc_curve(lr, X, y, ax=ax)
viz_gbc = plot_roc_curve(gbc, X, y, ax=ax)
viz_rfc = plot_roc_curve(rfc, X, y, ax=ax)
ax.legend()
<matplotlib.legend.Legend at 0x10f168240>
fig, ax = plt.subplots()
viz_lr.plot(ax=ax)
viz_gbc.plot(ax=ax)
viz_rfc.plot(ax=ax)
ax.legend()
<matplotlib.legend.Legend at 0x1a23efbd30>
viz_lr.figure_