Created
September 23, 2016 06:01
-
-
Save kadnan/dcc675ca3bdca170ed21bcea2f6cb48e to your computer and use it in GitHub Desktop.
Prediction of Match results by running Naive Bayes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Labels : Lost, Draw, Won [-1,0,1] | |
Features | |
========== | |
Toss(Lost,Won) = [-1,1] | |
Bat(First, Second) = [-1,1] | |
""" | |
# Import Library of Gaussian Naive Bayes model | |
from sklearn.naive_bayes import GaussianNB | |
from sklearn.metrics import accuracy_score | |
import numpy as np | |
from sklearn.metrics import precision_recall_fscore_support as score | |
# Assigning Features | |
features = np.genfromtxt('train.csv',delimiter=',',usecols=(1,2),dtype=int) | |
labels = np.genfromtxt('train.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) | |
# | |
# # Predict Output | |
predicted = model.predict(features_test) | |
# print(predicted) | |
acc = accuracy_score(labels_test,predicted) | |
print(acc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment