application_vnd.jupyter.stderr_output_2.png text_plain_output_1.png
from sklearn import metrics

from sklearn.linear_model import LogisticRegression

import matplotlib.pyplot as plt #plotting

import numpy as np

import pandas as pd

import seaborn as sns #visualization

data = pd.read_csv('../input/stroke-prediction-dataset/healthcare-dataset-stroke-data.csv')

data.drop(['id'], axis=1, inplace=True)

data.isnull().sum()

data.isnull().sum()

strokes = len(data[data['stroke'] == 1])
no_strokes = data[data.stroke == 0].index
random_indices = np.random.choice(no_strokes, strokes, replace=False)
stroke_indices = data[data.stroke == 1].index
under_sample_indices = np.concatenate([stroke_indices, random_indices])
udata = data.loc[under_sample_indices]

from sklearn.linear_model import LogisticRegression
lr = LogisticRegression()
lr.fit(X_train, Y_train)

Y_pred = lr.predict(X_test)
features = np.array([[0, 78, 0, 0, 1, 3, 0, 60, 28.8, 1]])
prediction = lr.predict(features)

y_pred_proba = lr.predict_proba(X_test)[:, 1]
fpr, tpr, _ = metrics.roc_curve(Y_test, y_pred_proba)
plt.plot(fpr, tpr)
plt.ylabel('True Positive Rate')
plt.xlabel('False Positive Rate')
plt.title('ROC for Logistic Regression')
plt.show()