Support Vector Machine-Classification(Python)

0
198

Support Vector Machine-Classification:  We have already understood conceptually, how Support Vector Machine algorithm works. Let’s try to implement a SVM logic using Python commands.

We would use Loan Default data to implement SVM- Classification.

Step 1: Import the Libraries. We would use three libraries for this analysis:

  • numpy
  • pyplot
  • pandas

Use below command to import the libraries.

 

PYC_SVM1

Step 2: Import the data set.

 

PYC_SVM2

Step 3: Splitting the data set into the Training set and Test set. Provided data set has 300 observations, we would divide it into 75%-25% for training and testing purpose.

 

PYC_SVM3

Step 4: Feature Scaling: Since range of two of our predictor variables is very different, while Age varies from 18-60 whereas salary varies from 1127-142293. We need to do feature scaling so that both of the variables have same proportional impact on the target variable. In the following command we are excluding the target variable from feature scaling which is at position 3.

 

PYC_SVM4

Step 5: Fitting SVM to the Training set

 

PYC_SVM5

Step 6: Predicting the Test set results

PYC_SVM6

Step 7: Making the Confusion Matrix

PYC_SVM7

 

 

 

 

 

 

 

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here