/ssvm_python

Smooth Support Vector Machine for python

Primary LanguageJupyter NotebookMIT LicenseMIT

ssvm_python

SSVM is a reformulation of conventional SVM and can be solved by a fast Newton-Armijo algorithm.For more detail about SSVM, you can see this introduction.

This project use matlab engine for python to call matlab function, and create a sklearn-like way to use those functions

Functions

After import ssvm.py package, you can use Smooth Support Vector Classification(SSVC) & Smooth Support Vector Regression(SSVR) with function below:

  • .fit(data, label)
  • .predict(data)
  • .score(data, label)
  • .print_params()
  • .get_params()

just like sklearn, very easy, right:-)?

Usage

Please install python matlab api first.

You can use SSVC to classification or SSVR to do regression(notice: both linear-only).

1. First, download these files and move to your workpath

ssvc.mssvr.mssvm.py

2. In your python code, import package

  • if you want to use SSVC, use from ssvm import SSVC
  • if you want to use SSVR, use from ssvm import SSVR

3. Create ssvc/ssvr instance

  • ssvc = SSVC() or ssvr = SSVR()

4. Train data

  • ssvc.fit(data, label) or ssvr.fit(data, value)

notice that about input format:

  • data: shape must be (m, n) array-like type, which m is data size and n is feature number
  • label/value: shape must be (1, m) or (m, 1) array-like type, which m is data size

5.predict

use .predict(data) to predict##

Demo

you can see demo code in SSVC_Demo.ipynb & SSVR_Demo.ipynb

References

paper

matlab code