stMind

about Tech, Computer vision and Machine learning

機械学習ライブラリollを試す

Machine Learningの本だけを読んでいてもわからないので、色々な機械学習ライブラリを実際に動かしてみよう!ということで今回は、パーセプトロンを最近学習したので、パーセプトロンが使えるollを試してみます。


oll-0.3.tar.gzをダウンロードして、configure & make & sudo make installをしておきます。

データの準備

$ perl -MList::Util=shuffle -e 'print shuffle(<>)' < news20.binary > news20.random ←ワンライナーでshuffle
$ head -15000 news20.random > news20.train
$ tail -4996 news20.random > news20.test

学習

$ oll_train 
oll_train (P|AP|PA|PA1|PA2|CW) trainfile modelfile [devfile] -C=FLOAT -b=FLOAT -I=INT
P   : Perceptron
AP  : Averaged Perceptron
PA  : Passive Agressive
PA1 : Passive Agressive I
PA2 : Passive Agressive II
PAK : Kernelized Passive Agressive
CW  : Confidence Weighted
AL  : ALMA HD (heavy)
-C    Regularization Paramter (Default 1.0)
-b    Bias (Default 0.0)
-I    Iteration (Default 10, 0 = one pass without storing)

$oll_train P news20.train news20.model.p -C=2.0 -b=1.0 -I=10 ←Perceptronを使う
Read Done.
..........FINISH!

推定

$ oll_test news20.test news20.model.p
Accuracy 94.576% (4725/4996)
(Answer, Predict): (p,p):2482 (p,n):37 (n,p):234 (n,n):2243

ソースコードも読んだりしていこうかな。