<commit_before># rb-libsvm -- Ruby language bindings for LIBSVM

Spec Status: [![Build Status](https://secure.travis-ci.org/febeling/rb-libsvm.png)](http://travis-ci.org/febeling/rb-libsvm)

This is a module which provides a Ruby API to the LIBSVM [1] library.
SVM is a machine learning and classification algorithm, and LIBSVM is
a popular free implementation of it, written by <NAME> and
<NAME>, of National Taiwan University, Taipei. See "Programming
Collective Intelligence," [2] among others, for a usage example.

Note: There exists another Ruby binding for LIBSVM, named Ruby SVM,
[3] written by <NAME>. (That's the one mentioned in the
libsvm documentation.) This package is not related but written
independently and from scratch.

## Dependencies

None.  Libsvm is bundled with the project.  Just install and go!

Currently using libsvm version 3.1

## Installation

    gem install rb-libsvm

## Usage

    require 'libsvm'

    # This library is namespaced.
    problem = Libsvm::Problem.new
    parameter = Libsvm::SvmParameter.new

    parameter.cache_size = 1 # in megabytes

    parameter.eps = 0.001
    parameter.c = 10

    examples = [ [1,0,1], [-1,0,-1] ].map {|ary| Libsvm::Node.features(ary) }
    labels = [1, -1]

    problem.set_examples(labels, examples)

    model = Libsvm::Model.train(problem, parameter)

    pred = model.predict(Libsvm::Node.features(1, 1, 1))
    puts "Example [1, 1, 1] - Predicted #{pred}"


## Author, License

Written by <NAME>. This software can be freely used under
the terms of the MIT license, see file MIT-LICENSE.

This package includes the source of LIBSVM, which is free to use under
the license in the file LIBSVM-LICENSE.

## Contributors

[<NAME>](https://github.com/neovintage)

[<NAME>](https://github.com/apohllo)

### Posts about SVMs and Ruby

[http://neovintage.blogspot.com/2011/11/text-classification-using-support.html](http://neovintage.blogspot.com/2011/11/text-classification-using-support.html)

[http://www.igvita.com/2008/01/07/support-vector-machines-svm-in-ruby/](http://www.igvita.com/2008/01/07/support-vector-machines-svm-in-ruby/)


### Notes

[http://www.csie.ntu.edu.tw/~cjlin/libsvm/](http://www.csie.ntu.edu.tw/~cjlin/libsvm/)

[http://books.google.com/books?id=fEsZ3Ey-Hq4C](http://books.google.com/books?id=fEsZ3Ey-Hq4C)

[http://rubysvm.cilibrar.com/](http://rubysvm.cilibrar.com/)

<commit_msg>Update libsvm version mentioned, drop dead link in README<commit_after># rb-libsvm -- Ruby language bindings for LIBSVM

Spec Status: [![Build Status](https://secure.travis-ci.org/febeling/rb-libsvm.png)](http://travis-ci.org/febeling/rb-libsvm)

This is a module which provides a Ruby API to the LIBSVM [1] library.
SVM is a machine learning and classification algorithm, and LIBSVM is
a popular free implementation of it, written by <NAME> and
<NAME>, of National Taiwan University, Taipei. See "Programming
Collective Intelligence," [2] among others, for a usage example.

Note: There exists another Ruby binding for LIBSVM, named Ruby SVM,
[3] written by <NAME>. (That's the one mentioned in the
libsvm documentation.) This package is not related but written
independently and from scratch.

## Dependencies

None.  Libsvm is bundled with the project.  Just install and go!

Currently using libsvm version 3.12

## Installation

    gem install rb-libsvm

## Usage

    require 'libsvm'

    # This library is namespaced.
    problem = Libsvm::Problem.new
    parameter = Libsvm::SvmParameter.new

    parameter.cache_size = 1 # in megabytes

    parameter.eps = 0.001
    parameter.c = 10

    examples = [ [1,0,1], [-1,0,-1] ].map {|ary| Libsvm::Node.features(ary) }
    labels = [1, -1]

    problem.set_examples(labels, examples)

    model = Libsvm::Model.train(problem, parameter)

    pred = model.predict(Libsvm::Node.features(1, 1, 1))
    puts "Example [1, 1, 1] - Predicted #{pred}"


## Author, License

Written by <NAME>. This software can be freely used under
the terms of the MIT license, see file MIT-LICENSE.

This package includes the source of LIBSVM, which is free to use under
the license in the file LIBSVM-LICENSE.

## Contributors

[<NAME>](https://github.com/neovintage)

[<NAME>](https://github.com/apohllo)

### Posts about SVMs and Ruby

[http://neovintage.blogspot.com/2011/11/text-classification-using-support.html](http://neovintage.blogspot.com/2011/11/text-classification-using-support.html)

[http://www.igvita.com/2008/01/07/support-vector-machines-svm-in-ruby/](http://www.igvita.com/2008/01/07/support-vector-machines-svm-in-ruby/)


### Notes

[http://www.csie.ntu.edu.tw/~cjlin/libsvm/](http://www.csie.ntu.edu.tw/~cjlin/libsvm/)

[http://books.google.com/books?id=fEsZ3Ey-Hq4C](http://books.google.com/books?id=fEsZ3Ey-Hq4C)
{'fraction_non_alphanumeric': 0.13438485804416403, 'fraction_numerical': 0.024605678233438486, 'mean_word_length': 4.001051524710831, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 6, 'lorem ipsum': 0, 'www.': 8, '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': '2381964', 'n_tokens_mistral': 1750, 'n_tokens_neox': 1605, 'n_words': 439}