text_plain_output_1.png
from sklearn.linear_model import LogisticRegression

from sklearn.metrics import accuracy_score, recall_score, precision_score, f1_score

from sklearn.metrics import recall_score, precision_score, accuracy_score

from sklearn.model_selection import train_test_split

import matplotlib.pyplot as plt

import numpy as np

import pandas as pd

import seaborn as sns

pima = pd.read_csv('../input/pimacsv/pima.csv')

pima.shape

#Your code (first create a correlation matrix and store it in 'corm' variable, and uncomment lines below)

corm = pima.iloc[:,:-1].corr()
masko = np.zeros_like(corm, dtype = np.bool)
masko[np.triu_indices_from(masko)] = True
fig, ax = plt.subplots(figsize = (10,5))
sns.heatmap(corm, mask = masko, cmap = 'coolwarm', annot=True)

X = pima.loc[:, pima.columns != 'Outcome']

y = pima.loc[:, 'Outcome']

from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=10)

from sklearn.linear_model import LogisticRegression
logr = LogisticRegression(random_state=0)
logr.fit(X_train, y_train)

from sklearn.metrics import confusion_matrix
from sklearn.metrics import accuracy_score, recall_score, precision_score, f1_score
ypred_train_logr = logr.predict(X_train)
ypred_test_logr = logr.predict(X_test)

print('Accuracy for test data is : \n', accuracy_score(y_test, ypred_test_logr), '\n')
print('Recall for test data is : \n', recall_score(y_test, ypred_test_logr), '\n')
print('Precision for test data is : \n', precision_score(y_test, ypred_test_logr), '\n')
print('f1-score for test data is : \n', f1_score(y_test, ypred_test_logr), '\n')