CentOS5.8のperlでSVM インストールメモ

libsvmのインストール:
http://d.hatena.ne.jp/hama_DU/20110923/1316745988


perlのインターフェース(Algorithm::SVM):
普通にCPANでインストール


すんなり行った


ただ、Algorithm::SVMのサンプルはそのままコピペでは動かない。

use Algorithm::SVM::DataSet;
use Algorithm::SVM;
use Data::Dumper;
use warnings;
use strict;


# Classify a dataset.
my $ds1 = new Algorithm::SVM::DataSet(Label => 1,
Data => [0.12, 0.25, 0.33, 0.98]);
my $ds2 = new Algorithm::SVM::DataSet(Label => 2,
Data => [0.15, 0.21, 0.31, 0.91]);
my @tset = ($ds1, $ds2);

# Load the model stored in the file 'sample.model'
#my $svm = new Algorithm::SVM(Model => 'sample.model');
my $svm = new Algorithm::SVM();

# Train a new SVM on some new datasets.
$svm->train(@tset);

$svm->save('new-sample.model');

みたいに、DataSetを@tsetに入れて、それをtrainに入れる。