text_plain_output_1.png
from sklearn.linear_model import LogisticRegression

from sklearn.linear_model import LogisticRegression

from sklearn.metrics import confusion_matrix

import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

df = pd.read_csv('../input/heart.csv')

df.shape

df.target.value_counts()

sns.set_style('whitegrid')

dataset = pd.get_dummies(df, columns=['sex', 'cp', 'fbs', 'restecg', 'exang', 'slope', 'ca', 'thal'])

lr = LogisticRegression()

lr.fit(X_train, y_train)

pred = lr.predict(X_test)
pred

confusion_matrix = pd.crosstab(y_test, pred, rownames=['Actual'], colnames=['prediction'])
confusion_matrix

plt.figure(figsize=(12, 7))
plt.title('Confusion Matrix')
sns.heatmap(confusion_matrix, annot=True, cmap='coolwarm')