[問題] Vector使用問題

作者: iphone5566s (哀鳳最終款)   2015-12-28 15:45:11
現在要用SVM來做辨識
他要餵的資料有點麻煩
是這樣的
Label ATTR1 ATTR2 ATTR3 ...
1 1:0 2:0.5 3:0.4 ... <- index:value
2
3
...
也就是我會需要
一個 int -> 紀錄label數量
一個 int[] -> 紀錄label對應順序
一個 double[][] -> 紀錄每個label對應的attr(index:value)
前兩個沒什麼問題,在第三個不太曉得要怎麼實作
使用
Vector vx = new Vector();
svm_node[] x = new svm_node[3];
x[0] = new svm_node();
x[0].index = color_r;
x[0].value = 15.0;
x[1] = new svm_node();
x[1].index = color_g;
x[1].value = 163.0;
x[2] = new svm_node();
x[2].index = color_b;
x[2].value = 15.0;
vx.addElement(x);
x[0].value = 255.0;
x[1].value = 42.0;
x[2].value = 0.0;
vx.addElement(x);
這樣的話,會變成原本15,163,15那組不見了,變成兩組都是255,42,0
我在http://www.interinfo.com.tw/edoc/ch20/frontline.htm
看到的意思,認為他是推疊上去的,但實作起來又會被蓋掉
還請各位大大指導一下以糾正錯誤的觀念,非常感謝!
參考的是這篇
http://function1122.blogspot.tw/2011/01/javalibsvm-144.html
作者: n3oanderson (wake up ...)   2015-12-29 12:02:00
作者: iphone5566s (哀鳳最終款)   2015-12-29 17:13:00
安德森大大是建議我可以使用這套演算法嗎~
作者: andy13579372 (痘糖)   2015-12-30 12:44:00
第二次應該還是要new svm node,不然會使用同一個物件
作者: jiqian (JIM)   2015-12-31 10:07:00
他是類似指標,你這樣vx(0),vx(1)都是指向x

Links booklink

Contact Us: admin [ a t ] ucptt.com