regression- Naive- SVM.docx
regression- Naive- SVM.docx
Aim
To evaluate and compare the performance of Linear Regression, Logistic
Regression, Naïve Bayes, and Support Vector Machine (SVM) models for heart
disease diagnosis
Algorithm
Step 1: Load the Dataset
● Split the dataset into training (80%) and testing (20%) sets using
train_test_split().
● Logistic Regression
● Naïve Bayes (GaussianNB)
● Support Vector Machine (SVM)
# Initialize models
logistic_model = LogisticRegression(max_iter=1000)
naive_bayes_model = GaussianNB()
svm_model = SVC()
# Make predictions
logistic_predictions = logistic_model.predict(X_test)
naive_bayes_predictions = naive_bayes_model.predict(X_test)
svm_predictions = svm_model.predict(X_test)
print("Naïve Bayes:")
print(f"Accuracy: {accuracy_score(y_test,
naive_bayes_predictions):.4f}")
print(classification_report(y_test, naive_bayes_predictions))
Output
Result
Thus the SVM model achieved the highest accuracy ( ), followed by Logistic Regression
( ) and Naïve Bayes ( ) for heart disease diagnosis. The SVM model showed better
overall performance in terms of precision, recall, and F1-score.