diff --git a/machine_learning/gaussian_naive_bayes.py.broken.txt b/machine_learning/gaussian_naive_bayes.py.broken.txt index 7e9a8d7f6dcf..6be882854192 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()