From 9de53315dcd60f564a1eaa1887579cc433b2544d Mon Sep 17 00:00:00 2001 From: Rutu Bhanderi <140520663+rutubhanderi@users.noreply.github.com> Date: Thu, 3 Oct 2024 23:45:29 +0530 Subject: [PATCH 1/2] Update gaussian_naive_bayes.py The algorithm section now provides a clear overview of the steps the program follows, making it easier to understand the flow of the code. --- .../gaussian_naive_bayes.py.broken.txt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/machine_learning/gaussian_naive_bayes.py.broken.txt b/machine_learning/gaussian_naive_bayes.py.broken.txt index 7e9a8d7f6dcf..727eacd15873 100644 --- a/machine_learning/gaussian_naive_bayes.py.broken.txt +++ b/machine_learning/gaussian_naive_bayes.py.broken.txt @@ -1,18 +1,24 @@ # Gaussian Naive Bayes Example import time - from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import accuracy_score, plot_confusion_matrix from sklearn.model_selection import train_test_split from sklearn.naive_bayes import GaussianNB - def main(): - """ Gaussian Naive Bayes Example using sklearn function. Iris type dataset is used to demonstrate algorithm. + + Algorithm: + 1. Load Dataset: Import the Iris dataset. + 2. Data Preprocessing: Split dataset into features (X) and labels (y). + 3. Model Initialization: Initialize Gaussian Naive Bayes model. + 4. Model Training: Fit model using training data. + 5. Make Predictions: Predict labels for the test dataset. + 6. Evaluate Model: Calculate and display accuracy. + 7. Visualize Results: Generate and display a normalized confusion matrix. """ # Load Iris dataset @@ -37,7 +43,7 @@ def main(): x_test, y_test, display_labels=iris["target_names"], - cmap="Blues", # although, Greys_r has a better contrast... + cmap="Blues", # although Greys_r has better contrast... normalize="true", ) plt.title("Normalized Confusion Matrix - IRIS Dataset") @@ -47,6 +53,5 @@ def main(): final_accuracy = 100 * accuracy_score(y_true=y_test, y_pred=y_pred) print(f"The overall accuracy of the model is: {round(final_accuracy, 2)}%") - if __name__ == "__main__": main() From 3a032ffa9f51d3aed9560c45e6d5da773bd8ed1a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 3 Oct 2024 18:20:08 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- machine_learning/gaussian_naive_bayes.py.broken.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machine_learning/gaussian_naive_bayes.py.broken.txt b/machine_learning/gaussian_naive_bayes.py.broken.txt index 727eacd15873..6be882854192 100644 --- a/machine_learning/gaussian_naive_bayes.py.broken.txt +++ b/machine_learning/gaussian_naive_bayes.py.broken.txt @@ -10,7 +10,7 @@ def main(): """ Gaussian Naive Bayes Example using sklearn function. Iris type dataset is used to demonstrate algorithm. - + Algorithm: 1. Load Dataset: Import the Iris dataset. 2. Data Preprocessing: Split dataset into features (X) and labels (y).