GA将?開発日記~王理のその先へ~

ネタ勢最強を目指して絶賛開発中。

SVRも試す

 今度はsin関数の近似をさせてみました。

 train.txt

0.000000 1:0.000000
0.099833 1:0.100000
0.198669 1:0.200000
0.295520 1:0.300000
0.389418 1:0.400000
0.479426 1:0.500000
0.564642 1:0.600000
0.644218 1:0.700000
0.717356 1:0.800000
0.841471 1:1.000000
0.891207 1:1.100000
0.932039 1:1.200000
0.963558 1:1.300000
0.985450 1:1.400000
0.997495 1:1.500000
0.999574 1:1.600000
0.991665 1:1.700000
0.973848 1:1.800000
0.946300 1:1.900000
0.909297 1:2.000000
0.863209 1:2.100000
0.808496 1:2.200000
0.745705 1:2.300000
0.675463 1:2.400000
0.598472 1:2.500000
0.427380 1:2.700000
0.334988 1:2.800000
0.239249 1:2.900000
0.141120 1:3.000000
0.041581 1:3.100000
-0.157746 1:3.300000
-0.255541 1:3.400000
-0.350783 1:3.500000
-0.442520 1:3.600000
-0.529836 1:3.700000
-0.611858 1:3.800000
-0.687766 1:3.900000
-0.756802 1:4.000000
-0.818277 1:4.100000
-0.871576 1:4.200000
-0.916166 1:4.300000
-0.951602 1:4.400000
-0.977530 1:4.500000
-0.993691 1:4.600000
-0.999923 1:4.700000
-0.996165 1:4.800000
-0.982453 1:4.900000
-0.958924 1:5.000000
-0.925815 1:5.100000
-0.883455 1:5.200000
-0.832267 1:5.300000
-0.705540 1:5.500000
-0.631267 1:5.600000
-0.550686 1:5.700000
-0.464602 1:5.800000
-0.373877 1:5.900000
-0.279415 1:6.000000

 test.txt

0.783327 1:0.900000
0.515501 1:2.600000
-0.772764 1:5.400000
-0.058374 1:3.200000

 svm-train -s 3 train.txtでepsilon-svr、-s 4でnu-SVRってモノになるらしいです。

 epsilon-SVRの結果

*.
Warning: using -h 0 may be faster
*
optimization finished, #iter = 167
nu = 0.039137
obj = -0.892287, rho = 0.016616
nSV = 10, nBSV = 0

C:\Users\Yuichi\Desktop\libsvm-3.1\libsvm-3.1\windows>svm-predict test3.txt train3.txt.model out.txt
Mean squared error = 0.0064571 (regression)
Squared correlation coefficient = 0.999834 (regression)

C:\Users\Yuichi\Desktop\libsvm-3.1\libsvm-3.1\windows>type out.txt
0.683841
0.432326
-0.677922
-0.0541555

C:\Users\Yuichi\Desktop\libsvm-3.1\libsvm-3.1\windows>type test3.txt
0.783327 1:0.900000
0.515501 1:2.600000
-0.772764 1:5.400000
-0.058374 1:3.200000

 nu-SVRの結果

.
Warning: using -h 0 may be faster
...................................*...*
optimization finished, #iter = 4775
epsilon = 0.000212
obj = -1.263724, rho = 0.026113
nSV = 43, nBSV = 15

C:\Users\Yuichi\Desktop\libsvm-3.1\libsvm-3.1\windows>svm-predict test3.txt train3.txt.model out.txt
Mean squared error = 1.13443e-007 (regression)
Squared correlation coefficient = 1 (regression)

C:\Users\Yuichi\Desktop\libsvm-3.1\libsvm-3.1\windows>type out.txt
0.783617
0.515238
-0.773035
-0.0588507

C:\Users\Yuichi\Desktop\libsvm-3.1\libsvm-3.1\windows>type test3.txt
0.783327 1:0.900000
0.515501 1:2.600000
-0.772764 1:5.400000
-0.058374 1:3.200000

 これだけ見ると、nu-SVRの方が優れているみたいですね。即断は禁物ですが。