From 59368ee8a12d0166d17da53afb80805de50e8a8a Mon Sep 17 00:00:00 2001 From: Prince Gangurde <50592495+Prince326@users.noreply.github.com> Date: Mon, 13 Apr 2020 02:57:07 +0530 Subject: [PATCH 1/3] Create Gaussian_Naive_Bayes.py Added Gaussian Naive Bayes algorithm in the module machine learning --- machine_learning/Gaussian_Naive_Bayes.py | 45 ++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 machine_learning/Gaussian_Naive_Bayes.py diff --git a/machine_learning/Gaussian_Naive_Bayes.py b/machine_learning/Gaussian_Naive_Bayes.py new file mode 100644 index 000000000000..24c884adb98a --- /dev/null +++ b/machine_learning/Gaussian_Naive_Bayes.py @@ -0,0 +1,45 @@ +# Gaussian Naive Bayes Example + +from sklearn.naive_bayes import GaussianNB +from sklearn.metrics import plot_confusion_matrix +from sklearn.datasets import load_iris +from sklearn.model_selection import train_test_split +import matplotlib.pyplot as plt + + +def main(): + + """ + Gaussian Naive Bayes Example using sklearn function. + Iris type dataset is used to demonstrate algorithm. + """ + + # Load Iris dataset + iris = load_iris() + + # Split dataset into train and test data + X = iris["data"] # features + Y = iris["target"] + x_train, x_test, y_train, y_test = train_test_split( + X, Y, test_size=0.3, random_state=1 + ) + + # Gaussian Naive Bayes + NB_model = GaussianNB() + NB_model.fit(x_train, y_train) + + # Display Confusion Matrix + plot_confusion_matrix( + NB_model, + x_test, + y_test, + display_labels=iris["target_names"], + cmap="Blues", + normalize="true", + ) + plt.title("Normalized Confusion Matrix - IRIS Dataset") + plt.show() + + +if __name__ == "__main__": + main() From bec21531dd11a72d757f7315e5ea6dba0cccece6 Mon Sep 17 00:00:00 2001 From: Prince Gangurde <50592495+Prince326@users.noreply.github.com> Date: Wed, 15 Apr 2020 00:11:34 +0530 Subject: [PATCH 2/3] Rename Gaussian_Naive_Bayes.py to gaussian_naive_bayes.py --- .../{Gaussian_Naive_Bayes.py => gaussian_naive_bayes.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename machine_learning/{Gaussian_Naive_Bayes.py => gaussian_naive_bayes.py} (100%) diff --git a/machine_learning/Gaussian_Naive_Bayes.py b/machine_learning/gaussian_naive_bayes.py similarity index 100% rename from machine_learning/Gaussian_Naive_Bayes.py rename to machine_learning/gaussian_naive_bayes.py From 48c252e615a286427b8d992043e15a219e0ff569 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 14 Apr 2020 21:31:32 +0200 Subject: [PATCH 3/3] requirements.txt: pip install xgboost --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index df5bcbafb2b6..9d6cc502bde1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,3 +15,4 @@ scikit-fuzzy sklearn sympy tensorflow; python_version < '3.8' +xgboost