0% found this document useful (0 votes)
5 views2 pages

Yall

Uploaded by

yallbethel5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Yall

Uploaded by

yallbethel5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

import pandas as pd

from sklearn.model_selection import train_test_split

from sklearn.linear_model import LogisticRegression

from sklearn.metrics import accuracy_score, confusion_matrix

# Load the data

data = pd.read_csv('heart_disease.csv')

# Separate features (X) and target variable (y)

X = data.drop('Heart Disease', axis=1)

y = data['Heart Disease']

# Split the data into training and testing sets

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Create a logistic regression model

model = LogisticRegression()

# Train the model on the training data

model.fit(X_train, y_train)

# Make predictions on the testing data

y_pred = model.predict(X_test)

# Evaluate the model's performance

accuracy = accuracy_score(y_test, y_pred)

print("Accuracy:", accuracy)

# Print the confusion matrix


cm = confusion_matrix(y_test, y_pred)

print("Confusion Matrix:\n", cm)

You might also like