Skip to main content
PySVMLight
==========

A Python binding to the [SVM-Light](http://svmlight.joachims.org/) support vector machine library by Thorsten Joachims.

Written by Bill Cauchois (<wcauchois@gmail.com>), with thanks to Lucas Beyer and n0mad for their contributions.

Installation
------------
PySVMLight uses distutils for setup. Installation is as simple as

$ chmod +x setup.py
$ ./setup.py --help
$ ./setup.py build

If you want to install SVMLight to your PYTHONPATH, type:

$ ./setup.py install

(You may need to execute this command as the superuser.) Otherwise, look in the build/ directory to find svmlight.so and copy that file to the directory of your project. You should now be able to `import svmlight`.

Getting Started
---------------
See examples/simple.py for example usage.

Reference
---------

If you type `help(svmlight)`, you will see that there are currently three functions.

learn(training_data, **options) -> model

Train a model based on a set of training data. The training data should be in the following format:

>> (<label>, [(<feature>, <value>), ...])

or

>> (<label>, [(<feature>, <value>), ...], <queryid>)

See examples/data.py for an example of some training data. Available options include (corresponding roughly to the command-line options for `svmlight` detailed on [this page](http://svmlight.joachims.org/) under the section titled "How to use"):

- `type`: select between 'classification', 'regression', 'ranking' (preference ranking), and 'optimization'.
- `kernel`: select between 'linear', 'polynomial', 'rbf', and 'sigmoid'.
- `verbosity`: set the verbosity level (default 0).
- `C`: trade-off between training error and margin.
- `poly_degree`: parameter d in polynomial kernel.
- `rbf_gamma`: parameter gamma in rbf kernel.
- `coef_lin`
- `coef_const`

The result of this call is a model that you can pass to classify().

classify(model, test_data, **options) -> predictions

Classify a set of test data using the provided model. The test data should be in the same format as training data (see above). The result will be a list of floats, corresponding to predicted labels for each of the test instances.

write_model(model, filename) -> None

Write the provided model to the specified file. The file format used is the same format as that used by the command-line `svmlight` program.

read_model(filename) -> model

Read a model that was saved using write_model().

Release files for svmlight 0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for svmlight 0.4
File Size Uploaded
svmlight-0.4.tar.gz 54.9 kB Details

Release files / svmlight-0.4.tar.gz

Download URL svmlight-0.4.tar.gz
Size 54.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3b6244050c9ee1f97ae8b305030851c757d98870ee7b3a1b9c9ea5e725d27541
BLAKE2b-256 checksum
How to use checksums
1105dd324f7084b151460d1890c138fbbe07e71bcc5770b5953715090413dc52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.4 This release

1 release file

0.3

1 release file

0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page