-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPrediction(NB).py
38 lines (28 loc) · 1017 Bytes
/
Prediction(NB).py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
Labels : Lost, Draw, Won [-1,0,1]
Features --
==========
Toss(Lost,Won) = [-1,1]
Bat(First, Second) = [-1,1]
"""
# Import Library - Gaussian Naive Bayes model
from sklearn.naive_bayes import GaussianNB
from sklearn.metrics import accuracy_score
# Import Numpy
import numpy as np
from sklearn.metrics import precision_recall_fscore_support as score
# Assigning Features
features = np.genfromtxt('Trained_Data.csv',delimiter=',',usecols=(1,2),dtype=int)
labels = np.genfromtxt('Trained_Data.csv',delimiter=',',usecols=(0),dtype=int)
features_test = np.genfromtxt('Test.csv',delimiter=',',usecols=(1,2),dtype=int)
labels_test = np.genfromtxt('Test.csv',delimiter=',',usecols=(0),dtype=int)
# Create a Gaussian Classifier
model = GaussianNB()
# Train the model using the training sets
model.fit(features, labels)
# Prediction rate
predicted = model.predict(features_test)
# print(predicted)
# Prediction Accuracy
accuracy = accuracy_score(labels_test,predicted)
print(accuracy)