from sklearn.linear_model import LogisticRegression 
from sklearn.metrics import confusion_matrix,classification_report 
from sklearn.model_selection import cross_val_score
from sklearn.model_selection import train_test_split
from sklearn.metrics import roc_auc_score
from sklearn import datasets
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np


df = pd.read_csv('Codes/Algo Implement/diabetes.csv')
X = df.drop(columns='diabetes')
y = df['diabetes']

#print(df.head())
#y = y.reshape(-1,1)

#print(y)

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.4, random_state=42)

logreg = LogisticRegression(solver='lbfgs')

# Fit the classifier to the training data
logreg.fit(X_train, y_train)

# Predict the labels of the test set: y_pred
y_pred = logreg.predict(X_test)

# Compute and print the confusion matrix and classification report
print('Comfusion matrix :', confusion_matrix(y_test, y_pred).ravel())
print('Classification report :',classification_report(y_test, y_pred))

# Compute predicted probabilities: y_pred_prob
y_pred_prob = logreg.predict_proba(X_test)[:,1]

# Compute and print AUC score
print("AUC: {}".format(roc_auc_score(y_test,y_pred_prob)))


'''
# Compute cross-validated AUC scores: cv_auc
cv_auc = cross_val_score(logreg, X,y, cv=5, scoring='roc_auc')

# Print list of AUC scores
print("AUC scores computed using 5-fold cross-validation: {}".format(cv_auc))

'''