Skip to content

Instantly share code, notes, and snippets.

@shreesundara
Created October 20, 2020 06:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shreesundara/b332c4bf39b0cd86933d64f4b59eb99d to your computer and use it in GitHub Desktop.
Save shreesundara/b332c4bf39b0cd86933d64f4b59eb99d to your computer and use it in GitHub Desktop.

#TWIML Fest https://twimlai.com/twimlfest/

#Show and Tell! ML/AI Project Lightning Talks https://twimlai.com/twimlfest/sessions/show-and-tell/

Exploratory analysis of SVM support vectors

Presenter

Shree Phani Sundara GitHub: https://github.com/shreesundara ; LinkedIn: https://www.linkedin.com/in/shreephani/

Context

Supervised Machine Learning algorithms i.e. Support vector machines are being used extensively which involves the process of training the model and interpreting the model behaviour. The complexity of understanding the model behaviour w.r.t the trained dataset increases with the increase in the number of support vectors generated. The idea here is to optimize the model, for improving model interpretation, by determining the minimal support vectors that effectively represents the original support-vector space, removing the noisy support vectors which may result in overfitting the model.

Description

The minimal optimal support vectors is determined by recursively removing the original support vectors from train data and re-training the model with resultant dataset and comparing the model results (the confusion-matrix and the accuracy) i.e.

  1. Build a linear SVM and identify the hyperplane for the IoT dataset (D1). Identify the Support Vectors (SV1) that contribute in defining Hyper plane HP1. Measure Accuracy of the model
  2. Now create a new training dataset (D2) by excluding the identified support vectors (SV1) for the original dataset (D1)
  3. Build a model using the training data obtained in the above step and identify the next set of support Vectors (SV2)
  4. Measure the Accuracy for above and repeat steps 2, 3, 4 till we identify min-imal set of support vectors needed to build the model.

Code

Link to code repository :- https://github.com/shreesundara/Exploratory-SVM-analysis

Results, Outcomes, Conclusions

Applied the above recursive methodology on Linear SVM models for the IoT malware dataset and observed that the optimal support vectors needed we reduced from 157 to 6 in the first iteration without deviation in accuracy/confusion-matrix results of the model.

Python libraries used

NumPy, Sklearn, Pandas

Open questions/issues

  • Does varying the SVM controlled parameters like C, Kernel-type provide similar results?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment