Reputation: 2669
I have a variable which contains some parameters which affect a created weka model. I want to change automatically the parameters values. I ve got the following:
String c [] ={"1.0", "10.0", "20.0", "30.0", "40.0", "50.0", "60.0","70.0", "80.0",
"90.0","100.0", "200.0", "300.0", "400.0","500.0", "600.0", "700.0", "800.0", "1000.0",
"2000.0"};
System.out.println(c[1]);
String opt = ("-C "+c[0] +"-L 0.001 -P 1.0E-12 -N 0 -V -1 -W 1 -K
weka.classifiers.functions.supportVector.PolyKernel -C 250007 -E 1.0 ");
String [] options = opt.split(" ");
obj.train(new File(obj.str.get(2)), options);
I want to change inside the loop automatically the C parameter. However, when I wrote the below:
String opt = ("-C "+c[1] +"-L 0.001 -P 1.0E-12 -N 0 -V -1 -W 1 -K weka.classifiers.functions.supportVector.PolyKernel -C 250007 -E 1.0 ");
I am receiving a java.lang.NumberFormatException
: For input string. What I might have to do , to work proper? The error is in last line of the above code.
Upvotes: 1
Views: 3608
Reputation: 619
i give it a try:
String c [] ={"1.0", "10.0", "20.0", "30.0", "40.0", "50.0", "60.0","70.0", "80.0", "90.0","100.0", "200.0", "300.0", "400.0","500.0", "600.0", "700.0", "800.0", "1000.0", "2000.0"};
for (i = 0; i < c.length; i++){
String opt = String.format("-C %S 1.0 -L 0.001 -P 1.0E-12 -N 0 -V -1 -W 1 -K weka.classifiers.functions.supportVector.PolyKernel -C 250007 -E 1.0 ",c[i]);
}
i used String.format("", ...) function and added %S as placeholder where the value of c[i] will be put into.
Upvotes: 3