<commit_before>Libsvm
====
Libsvm is a simple, easy-to-use, and efficient software for SVM
classification and regression. It solves C-SVM classification, nu-SVM
classification, one-class-SVM, epsilon-SVM regression, and nu-SVM
regression. It also provides an automatic model selection tool for
C-SVM classification. This document explains the use of libsvm.

Libsvm is available at 
http://www.csie.ntu.edu.tw/~cjlin/libsvm
Please read the COPYRIGHT file before using libsvm.

##Table of Contents

- Quick Start
- Installation and Data Format
- `svm-train' Usage
- `svm-predict' Usage
- `svm-scale' Usage
- Tips on Practical Use
- Examples
- Precomputed Kernels 
- Library Usage
- Java Version
- Building Windows Binaries
- Additional Tools: Sub-sampling, Parameter Selection, Format checking, etc.
- MATLAB/OCTAVE Interface
- Python Interface
- Additional Information

##Quick Start

If you are new to SVM and if the data is not large, please go to 
`tools` directory and use easy.py after installation. It does 
everything automatic -- from data scaling to parameter selection.

Usage: easy.py training_file [testing_file]

More information about parameter selection can be found in
`tools/README.`

##Installation and Data Format

On Unix systems, type `make` to build the `svm-train` and `svm-predict`
programs. Run them without arguments to show the usages of them.

On other systems, consult `Makefile` to build them (e.g., see
'Building Windows binaries` in this file) or use the pre-built
binaries (Windows binaries are in the directory `windows`).

The format of training and testing data file is:

`<label> <index1>:<value1> <index2>:<value2> ...`
.
.
.

Each line contains an instance and is ended by a `'\n'` character.  For
classification, `<label>` is an integer indicating the class label
(multi-class is supported). For regression, `<label>` is the target
value which can be any real number. For one-class SVM, it's not used
so can be any number.  The pair `<index>:<value>` gives a feature
(attribute) value: `<index>` is an integer starting from 1 and `<value>`
is a real number. The only exception is the precomputed kernel, where
`<index>` starts from 0; see the section of precomputed kernels. Indices
must be in ASCENDING order. Labels in the testing file are only used
to calculate accuracy or errors. If they are unknown, just fill the
first column with any numbers.

A sample classification data included in this package is
`heart_scale'. To check if your data is in a correct form, use
`tools/checkdata.py' (details in `tools/README').

Type `svm-train heart_scale', and the program will read the training
data and output the model file `heart_scale.model'. If you have a test
set called heart_scale.t, then type `svm-predict heart_scale.t
heart_scale.model output' to see the prediction accuracy. The `output'
file contains the predicted class labels.

For classification, if training data are in only one class (i.e., all
labels are the same), then `svm-train' issues a warning message:
`Warning: training data in only one class. See README for details,'
which means the training data is very unbalanced. The label in the
training data is directly returned when testing.

There are some other useful programs in this package.

svm-scale:

	This is a tool for scaling input data file.

svm-toy:

	This is a simple graphical interface which shows how SVM
	separate data in a plane. You can click in the window to 
	draw data points. Use "change" button to choose class 
	1, 2 or 3 (i.e., up to three classes are supported), "load"
	button to load data from a file, "save" button to save data to
	a file, "run" button to obtain an SVM model, and "clear"
	button to clear the window.

	You can enter options in the bottom of the window, the syntax of
	options is the same as `svm-train'.

	Note that "load" and "save" consider dense data format both in
	classification and the regression cases. For classification,
	each data point has one label (the color) that must be 1, 2,
	or 3 and two attributes (x-axis and y-axis values) in
	[0,1). For regression, each data point has one target value
	(y-axis) and one attribute (x-axis values) in [0, 1).

	Type `make' in respective directories to build them.

	You need Qt library to build the Qt version.
	(available from http://www.trolltech.com)

	You need GTK+ library to build the GTK version.
	(available from http://www.gtk.org)
	
	The pre-built Windows binaries are in the `windows'
	directory. We use Visual C++ on a 32-bit machine, so the
	maximal cache size is 2GB.

##`svm-train' Usage

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)
-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)<commit_msg>up to 1/3<commit_after>Libsvm
====
Libsvm is a simple, easy-to-use, and efficient software for SVM
classification and regression. It solves C-SVM classification, nu-SVM
classification, one-class-SVM, epsilon-SVM regression, and nu-SVM
regression. It also provides an automatic model selection tool for
C-SVM classification. This document explains the use of libsvm.

Libsvm is available at [http://www.csie.ntu.edu.tw/~cjlin/libsvm](http://www.csie.ntu.edu.tw/~cjlin/libsvm) Please read the **COPYRIGHT** file before using libsvm.


##Table of Contents

- Quick Start
- Installation and Data Format
- `svm-train` Usage
- `svm-predict` Usage
- `svm-scale` Usage
- Tips on Practical Use
- Examples
- Precomputed Kernels 
- Library Usage
- Java Version
- Building Windows Binaries
- Additional Tools: Sub-sampling, Parameter Selection, Format checking, etc.
- MATLAB/OCTAVE Interface
- Python Interface
- Additional Information

##Quick Start

If you are new to SVM and if the data is not large, please go to 
`tools` directory and use easy.py after installation. It does 
everything automatic -- from data scaling to parameter selection.

Usage: `easy.py training_file [testing_file]`

More information about parameter selection can be found in
`tools/README.`

##Installation and Data Format

On Unix systems, type `make` to build the `svm-train` and `svm-predict`
programs. Run them without arguments to show the usages of them.

On other systems, consult `Makefile` to build them (e.g., see
`Building Windows binaries` in this file) or use the pre-built
binaries (Windows binaries are in the directory `windows`).

The format of training and testing data file is:

`<label> <index1>:<value1> <index2>:<value2> ...`
.
.
.

Each line contains an instance and is ended by a `'\n'` character.  For
classification, `<label>` is an integer indicating the class label
(multi-class is supported). For regression, `<label>` is the target
value which can be any **real** number. For one-class SVM, it's not used
so can be any number.  The pair `<index>:<value>` gives a feature
(attribute) value: `<index>` is an integer starting from 1 and `<value>`
is a real number. The only exception is the precomputed kernel, where
`<index>` starts from 0; see the section of precomputed kernels. Indices
must be in ASCENDING order. Labels in the testing file are only used
to calculate accuracy or errors. If they are unknown, just fill the
first column with any numbers.

A sample classification data included in this package is
`heart_scale'. To check if your data is in a correct form, use
`tools/checkdata.py' (details in `tools/README').

Type `svm-train heart_scale`, and the program will read the training
data and output the model file `heart_scale.model`. If you have a test
set called `heart_scale.t`, then type `svm-predict heart_scale.t
heart_scale.model output` to see the prediction accuracy. The `output`
file contains the predicted class labels.

For classification, if training data are in only one class (i.e., all
labels are the same), then `svm-train` issues a warning message:
`Warning: training data in only one class. See README for details`,
which means the training data is very unbalanced. The label in the
training data is directly returned when testing.

There are some other useful programs in this package.

* **svm-scale:** This is a tool for scaling input data file.

* **svm-toy:** This is a simple graphical interface which shows how SVM separate data in a plane. You can click in the window to draw data points. Use "change" button to choose class 1, 2 or 3 (i.e., up to three classes are supported), "load" button to load data from a file, "save" button to save data to a file, "run" button to obtain an SVM model, and "clear" button to clear the window.

>You can enter options in the bottom of the window, the syntax of options is the same as `svm-train`.

>Note that "load" and "save" consider dense data format both in classification and the regression cases. For classification, each data point has one label (the color) that must be 1, 2, or 3 and two attributes (x-axis and y-axis values) in [0,1). For regression, each data point has one target value (y-axis) and one attribute (x-axis values) in [0, 1).

Type `make' in respective directories to build them.

You need Qt library to build the Qt version.	(available from [http://www.trolltech.com](http://www.trolltech.com))

You need GTK+ library to build the GTK version.(available from [http://www.gtk.org](http://www.gtk.org))
	
The pre-built Windows binaries are in the `windows` directory. We use Visual C++ on a 32-bit machine, so the maximal cache size is 2GB.

##`svm-train' Usage

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)
-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)
{'fraction_non_alphanumeric': 0.08673425179793778, 'fraction_numerical': 0.009531236461311845, 'mean_word_length': 4.042376583660987, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 9, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5947684', 'n_tokens_mistral': 3582, 'n_tokens_neox': 3395, 'n_words': 1690}