Skip to content

Instantly share code, notes, and snippets.

@AlicanAKCA
Last active December 13, 2020 11:48
Show Gist options
  • Save AlicanAKCA/1c5e1aca675679958d34a26da18ef660 to your computer and use it in GitHub Desktop.
Save AlicanAKCA/1c5e1aca675679958d34a26da18ef660 to your computer and use it in GitHub Desktop.
@author: Alican AKCA
"""
import pandas as pd #Kütüphaneleri ekledik!
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.svm import SVC
from sklearn.metrics import confusion_matrix
veriler = pd.read_csv('Datasets.csv') # We have loaded our dataset. Note that it is located in the same directory.
x = veriler.iloc[:,3:7].values # We will view our columns.
y = veriler.iloc[:,0:1].values # We will view our columns.
x_train, x_test,y_train,y_test = train_test_split(x,y,test_size=0.25, random_state=0)
# We allocated 25% of our data to our variables for learning.
sc=StandardScaler() #We scaled
X_train = sc.fit_transform(x_train) #We scaled
X_test = sc.transform(x_test) #We scaled
svc = SVC(kernel = "linear") #linear,sigmoid,rbf,poly
svc.fit(X_train,y_train) #Learn / Apply
y_pred = svc.predict(X_test) #will guess
cm =confusion_matrix(y_test, y_pred) #We'll see it in the complexity matrix.
print("Linear")
print(cm)
svc = SVC(kernel = "sigmoid")
svc.fit(X_train,y_train) #Learn / Apply
y_pred = svc.predict(X_test) #Will guess
cm =confusion_matrix(y_test, y_pred)
print("Sigmoid")
print(cm)
svc = SVC(kernel = "rbf")
svc.fit(X_train,y_train) #Learn / Apply
y_pred = svc.predict(X_test)#Will guess
cm =confusion_matrix(y_test, y_pred)
print("Sigmoid")
print(cm)
svc = SVC(kernel = "poly")
svc.fit(X_train,y_train)#Learn / Apply
y_pred = svc.predict(X_test) #Will guess
cm =confusion_matrix(y_test, y_pred)
print("Sigmoid")
print(cm)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment