-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsilmple-classifier.py
37 lines (29 loc) · 1.17 KB
/
silmple-classifier.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
#The original dataset was edited, adding the first rows as label in order to make the feature/output division easier
#Kernel tricks were used because of the non-linear dicision boundary
#Libraries
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.model_selection import train_test_split
from sklearn.svm import SVC
from sklearn.metrics import classification_report, confusion_matrix
#Reading the archive
data = pd.read_csv('vetsRots.txt',sep=' ',header=0)
#print(data.head)
#Setting the 'class' column as the output
x = data.drop('class',axis=1)
y = data['class']
#Here I ask the user to define a percentage for the train-test split
val = input("Insira a porcentagem de treino : ")
val = int(val)
print('O treino será de',val,'%')
valtreino = (val/100)
#Trani-test split
x_treino, x_teste, y_treino, y_teste = train_test_split(x, y, test_size = valtreino)
#Training the model using the Gaussian Kernel method
maquina = SVC(kernel='rbf')
maquina.fit(x_treino, y_treino)
#Predictions and accuracy response
y_prever = maquina.predict(x_teste)
print(classification_report(y_teste, y_prever))