<jupyter_start><jupyter_text>** Plotting ROC AUC**<jupyter_code># import libraries
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import roc_curve
from sklearn.metrics import auc
# data doesn't have headers, so let's create headers
_headers = ['Age', 'Delivery_Nbr', 'Delivery_Time', 'Blood_Pressure', 'Heart_Problem', 'Caesarian']
# read in cars dataset
df = pd.read_csv('https://raw.githubusercontent.com/PacktWorkshops/The-Data-Science-Workshop/master/Chapter06/Dataset/caesarian.csv.arff', names=_headers, index_col=None, skiprows=15)
df.head()

# target column is 'Caesarian'
features = df.drop(['Caesarian'], axis=1).values
labels = df[['Caesarian']].values

# split 80% for training and 20% into an evaluation set
X_train, X_eval, y_train, y_eval = train_test_split(features, labels, test_size=0.2, random_state=0)

# further split the evaluation set into validation and test sets of 10% each
X_val, X_test, y_val, y_test = train_test_split(X_eval, y_eval, test_size=0.5, random_state=0)

model = LogisticRegression()
model.fit(X_train, y_train)

y_proba = model.predict_proba(X_val)
from sklearn.metrics import roc_auc_score
_auc = roc_auc_score(y_val, y_proba[:, 0])
print(_auc)<jupyter_output>0.5833333333333334
{'fraction_non_alphanumeric': 0.11136363636363636, 'fraction_numerical': 0.026515151515151516, 'mean_word_length': 7.104294478527607, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '208630', 'license': 'MIT', 'n_tokens_mistral': 498, 'n_tokens_neox': 462, 'n_words': 114, 'path': 'Chapter06/Exercise6.13/Exercise6_13.ipynb', 'repo_name': 'khieunguyen/The-Data-Science-Workshop', 'size': '1320'}