Skip to content

Commit ae9cb24

Browse files
authored
Update Naive_Bayes_sklearn.py
1 parent 974f4c4 commit ae9cb24

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Naive Bayes/Naive_Bayes_sklearn.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
import numpy as np
22
from sklearn.datasets import load_wine
3+
from sklearn.model_selection import train_test_split
4+
from sklearn.naive_bayes import GaussianNB
5+
from sklearn.metrics import accuracy_score
36

47
wine = load_wine()
58

69
X = wine.data
710
y = wine.target
811

9-
from sklearn.model_selection import train_test_split
10-
1112
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 42)
1213

13-
from sklearn.naive_bayes import GaussianNB
14-
from sklearn.metrics import accuracy_score
15-
1614
nb = GaussianNB()
1715

1816
nb.fit(X_train, y_train)
1917

2018
y_pred = nb.predict(X_test)
2119

2220
accuracy = accuracy_score(y_test, y_pred) * 100
23-
print(f"Accuracy of Naive Bayes Model which implemented using sklearn is {accuracy:.2f}%")
21+
print(f"Accuracy of Naive Bayes Model which implemented using sklearn is {accuracy:.2f}%")

0 commit comments

Comments
 (0)