airanmehr / cssvm

Cost-Sensitive Support Vector Machines

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cost-Sensitive Support Vector Machines (CSSVM)

This project implements CSSVM using LibSVM.

  1. Installation

Installing CSSVM is exactly the same as LibSVM:

  1. Command line: In the root directory of the project and simply execute make.

  2. Python Interface In the python directory, execute make.

  3. Run

Running CSSVM is almost like running LibSVM, except the new -C and -W options:


Usage: svm-train [options] training_set_file [model_file]
options:
-s svm_type : set type of SVM (default 0)
	0 -- C-SVC		(multi-class classification)
	1 -- nu-SVC		(multi-class classification)
	2 -- one-class SVM
	3 -- epsilon-SVR	(regression)
	4 -- nu-SVR		(regression)
-t kernel_type : set type of kernel function (default 2)
	0 -- linear: u'*v
	1 -- polynomial: (gamma*u'*v + coef0)^degree
	2 -- radial basis function: exp(-gamma*|u-v|^2)
	3 -- sigmoid: tanh(gamma*u'*v + coef0)
	4 -- precomputed kernel (kernel values in training_set_file)
-C Cost-sensitive Learning Method(default 0):
	0 -- cost-insensitive SVM (biased-penalty SVM with option -w1 C_1 -w-1 C_-1)
	1 -- cost-sensitive SVM with option -w1 C_1 -w-1 1/kappa
	2 -- cost-sensitive SVM with example-dependent cost.used with option -W cost_file_name
-W cost_file_name : file contains example costs for example-dependent cost-sensitive learning
-d degree : set degree in kernel function (default 3)
-g gamma : set gamma in kernel function (default 1/num_features)
-r coef0 : set coef0 in kernel function (default 0)
-c cost : set the parameter C of C-SVC, epsilon-SVR, and nu-SVR (default 1)
-n nu : set the parameter nu of nu-SVC, one-class SVM, and nu-SVR (default 0.5)
-p epsilon : set the epsilon in loss function of epsilon-SVR (default 0.1)
-m cachesize : set cache memory size in MB (default 100)
-e epsilon : set tolerance of termination criterion (default 0.001)
-h shrinking : whether to use the shrinking heuristics, 0 or 1 (default 1)
-b probability_estimates : whether to train a SVC or SVR model for probability estimates, 0 or 1 (default 0)
-wi weight : set the parameter C of class i to weight*C, for C-SVC (default 1)
-v n: n-fold cross validation mode
-q : quiet mode (no outputs)
  1. CSSVM Tools

Several utiliy functions for training, grid search, and computind different performance measures is provided in cssvm_tools.py.

cssvmutil.py and cssvm.py containt python interface functions for CSSVM.

  1. Examples

Example scripts involving grid search, cross-validation, train and testing CSSVM is provided for each algorithm:

Cost-Sensitive Learning with Available Class-Dependent Costs (CSA): For the german dataset which its costs are known, run_german perfoms grid search, minimizing the (cost-sensitive) Risk to find the best hyperparameters and threshold for SVM, Biased-Penalty SVM, and CSSVM. The output of the can be found in the run_german.html

Cost-Sensitive Learning with Unavailable Class-Dependent Costs (CSU): (to be added)

Cost-Sensitive Learning with Example-Dependent Costs (CSE): (to be added)

  1. Cite

@article{masnadi2012cost, title={Cost-Sensitive Support Vector Machines}, author={Masnadi-Shirazi, Hamed and Vasconcelos, Nuno and Iranmehr, Arya}, journal={arXiv preprint arXiv:1212.0975}, year={2012} }

About

Cost-Sensitive Support Vector Machines

License:MIT License


Languages

Language:Python 46.1%Language:C++ 38.0%Language:C 15.9%