LIBSVM試してみました
http://d.hatena.ne.jp/Gasyou/comment?date=20110327#cでid:gamidereさんに教えてもらったLIBSVMというものを試してみました。
C++用のインタフェースもあるらしいのですが、とりあえずはコマンドライン版で。
インストール
http://www.csie.ntu.edu.tw/~cjlin/libsvm/からzipファイルをダウンロード→適当な場所に解凍
学習・分類
train.txt,test.txtとして以下の内容のファイルを準備。ファイルの書き方はhttp://www.okuma.nuee.nagoya-u.ac.jp/~sakaguti/wiki/index.php?LibSVMを参考にしました。
+1 0:1.0 1:0.0 +1 0:0.0 1:1.0 -1 0:0.0 1:0.0 -1 0:1.0 1:1.0
とりあえずは簡単なXORの学習です。
// 学習
svm-train.exe train.txt// 分類
svm-predict.exe test.txt train.txt.model out.txt
train.txt.modelはsvm-train.exeを実行すると自動的に生成される様です。
out.txtは以下の内容。ちゃんと分類出来てます。
1 1 -1 -1