@@ -0,0 +1,2276 @@
+/**%0A    This file is part of JkernelMachines.%0A%0A    JkernelMachines is free software: you can redistribute it and/or modify%0A    it under the terms of the GNU General Public License as published by%0A    the Free Software Foundation, either version 3 of the License, or%0A    (at your option) any later version.%0A%0A    JkernelMachines is distributed in the hope that it will be useful,%0A    but WITHOUT ANY WARRANTY; without even the implied warranty of%0A    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A    GNU General Public License for more details.%0A%0A    You should have received a copy of the GNU General Public License%0A    along with JkernelMachines.  If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A%0A    Copyright David Picard - 2012%0A%0A*/%0Apackage fr.lip6.example;%0A%0Aimport java.util.List;%0A%0Aimport fr.lip6.classifier.LaSVM;%0Aimport fr.lip6.classifier.multiclass.OneAgainstAll;%0Aimport fr.lip6.evaluation.MulticlassAccuracyEvaluator;%0Aimport fr.lip6.evaluation.NFoldCrossValidation;%0Aimport fr.lip6.kernel.typed.DoubleGaussL2;%0Aimport fr.lip6.type.TrainingSample;%0Aimport fr.lip6.util.DebugPrinter;%0Aimport fr.lip6.util.generators.MultiClassGaussianGenerator;%0A%0A/**%0A * @author picard%0A *%0A */%0Apublic class MulticlassExample %7B%0A%0A%09/**%0A%09 * Program entry point%0A%09 * @param args ignored%0A%09 */%0A%09public static void main(String%5B%5D args) %7B%0A%09%09%0A%09%09//set debug for visibility%0A%09%09DebugPrinter.DEBUG_LEVEL = 2;%0A%09%09%0A%09%09// new generator with 10 classes and stddev of 0.5%0A%09%09MultiClassGaussianGenerator mcg = new MultiClassGaussianGenerator();%0A%09%09mcg.setSigma(0.5);%0A%09%09mcg.setNbclasses(10);%0A%09%09%0A%09%09//generate the list%0A%09%09List%3CTrainingSample%3Cdouble%5B%5D%3E%3E list = mcg.generateList(100);%0A%09%09%0A%09%09//build classifier based on GaussL2 lasvm with c=10%0A%09%09DoubleGaussL2 k =new DoubleGaussL2(2);%0A%09%09LaSVM%3Cdouble%5B%5D%3E svm = new LaSVM%3Cdouble%5B%5D%3E(k);%0A%09%09svm.setC(10);%0A%09%09OneAgainstAll%3Cdouble%5B%5D%3E mcsvm = new OneAgainstAll%3Cdouble%5B%5D%3E(svm);%0A%09%09%0A%09%09%0A%09%09//doing crossvalidation with multiclass accuracy%0A%09%09MulticlassAccuracyEvaluator%3Cdouble%5B%5D%3E eval = new MulticlassAccuracyEvaluator%3Cdouble%5B%5D%3E();%0A%09%09NFoldCrossValidation%3Cdouble%5B%5D%3E cv = new NFoldCrossValidation%3Cdouble%5B%5D%3E(10, mcsvm, list, eval);%0A%09%09%0A%09%09//launch cv%0A%09%09cv.run();%0A%09%09%0A%09%09//print results %0A%09%09System.out.println(%22Multiclass accuracy: %22+cv.getAverageScore()+%22 +/- %22+cv.getStdDevScore());%0A%0A%09%7D%0A%0A%7D%0A

add multiclass example with generated data