import pandas as pd
df = pd.read_csv('http://bit.ly/kaggletrain')
cols = ['Pclass', 'Fare', 'SibSp']
X = df[cols]
y = df['Survived']
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import plot_roc_curve
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)
lr = LogisticRegression()
dt = DecisionTreeClassifier()
rf = RandomForestClassifier()
lr.fit(X_train, y_train);
dt.fit(X_train, y_train);
rf.fit(X_train, y_train);
disp = plot_roc_curve(lr, X_test, y_test)
plot_roc_curve(dt, X_test, y_test, ax=disp.ax_);
plot_roc_curve(rf, X_test, y_test, ax=disp.ax_);
© 2020 Data School. All rights reserved.