text_plain_output_1.png
from sklearn.linear_model import LogisticRegression

from sklearn.naive_bayes import GaussianNB

from sklearn.naive_bayes import GaussianNB

from sklearn.neighbors import KNeighborsClassifier

from sklearn.svm import SVC

from sklearn.tree import DecisionTreeClassifier

import numpy as np

import pandas as pd

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)

from sklearn.neighbors import KNeighborsClassifier
knn_classifier = KNeighborsClassifier(n_neighbors=3, metric='minkowski', p=3)
knn_classifier.fit(X_train, Y_train)

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

from sklearn import tree
dt_classifier = DecisionTreeClassifier()
dt_classifier.fit(X_train, Y_train)

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

from sklearn.naive_bayes import GaussianNB
gnb_classifier = GaussianNB()

gnb_classifier.fit(X_train, Y_train)
Y_pred_gnb = gnb_classifier.predict(X_test)
features = np.array([[0, 78, 0, 0, 1, 3, 0, 60, 28.8, 1]])
prediction = gnb_classifier.predict(features)

from sklearn.svm import SVC
svm_classifier = SVC()
svm_classifier.fit(X_train, Y_train)

Y_pred_svm = svm_classifier.predict(X_test)
features = np.array([[0, 78, 0, 0, 1, 3, 0, 60, 28.8, 1]])
prediction = svm_classifier.predict(features)
print('Prediction: {}'.format(prediction))