image_output_1.png
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]

udata