Created
November 26, 2016 01:30
-
-
Save aiscool/0f7c59d5d3dbcfe2ae1ad455d0d53c5a to your computer and use it in GitHub Desktop.
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
import matplotlib.pyplot as plt | |
from sklearn import svm,metrics | |
import pandas as pd | |
df = pd.read_csv('training-test.csv') | |
df = df.iloc[:,1:] | |
train = df.sample(frac=0.9, random_state=255) | |
test = df.drop(train.index) | |
train_in = train.drop(['class'], axis=1).values | |
train_out = train['class'].values | |
test_in = test.drop(['class'], axis=1).values | |
test_out = test['class'].values | |
cls = svm.SVC(gamma=0.001) | |
cls.fit(train_in,train_out) | |
expected = test_out | |
predicted = cls.predict(test_in) | |
print("Classification report for classifier %s:\n%s\n" | |
% (cls, metrics.classification_report(expected, predicted))) | |
print("Confusion matrix:\n%s" % metrics.confusion_matrix(expected, predicted)) | |
print("\nThe accuracy is : {:.2f}%".format(metrics.accuracy_score(expected,predicted)*100)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment