April 2018
Beginner to intermediate
282 pages
6h 52m
English
The process to create an SVM model is similar to other classification methods that we studied earlier. The only difference is to import the svm method from scikit-learn's library. We import the HR attrition dataset using pandas library and split the dataset to train and test sets:
import numpy as npimport pandas as pdfrom sklearn import svmfrom sklearn.metrics import accuracy_scorehr_data = pd.read_csv('data/hr.csv', header=0)hr_data.head()hr_data = hr_data.dropna()print(" Data Set Shape ", hr_data.shape)print(list(hr_data.columns))print(" Sample Data ", hr_data.head())data_trnsf = pd.get_dummies(hr_data, columns =['salary', 'sales'])data_trnsf.columnsX = data_trnsf.drop('left', axis=1)X.columnsfrom ...