-
Notifications
You must be signed in to change notification settings - Fork 0
/
SVM.py
31 lines (27 loc) · 880 Bytes
/
SVM.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
# -*- coding: utf-8 -*-
"""
Created on Mon Dec 2 14:43:26 2019
@author: mmrra
"""
####SVM
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
train = pd.read_csv("F:\MachineLearning\Datasets\Titanic/trainpp.csv")
test = pd.read_csv("F:\MachineLearning\Datasets\Titanic/testpp.csv")
train.head()
target=train["Survived"]
train_data=train.drop(["Survived"], axis=1)
from sklearn import svm
from sklearn.metrics import accuracy_score
from sklearn.model_selection import KFold
from sklearn.model_selection import cross_val_score
import warnings
warnings.filterwarnings('ignore')
k_fold = KFold(n_splits = 10, shuffle=True, random_state=0)
support = svm.LinearSVC(random_state=20)
scoring='accuracy'
score = cross_val_score(support, train_data, target, cv=k_fold, n_jobs=1, scoring=scoring)
print(score)
print(round(np.mean(score)*100, 2))