android - Error trying to call .buildClassifier (Weka) in Java AndroidStudio -
i trying use weka in android studio. , stuck @ line:
linearregresion.buildclassifier(data);
its red underlined , says:
unhandled exception:java.lang.exception
i trying other ways , different dataset , allways underlined @ .buildclassifier
//test: naivebayes nb = new naivebayes(); nb.buildclassifier(dataset); //unhandled exception classifier cmodel = (classifier)new linearregression(); cmodel.buildclassifier(data); //unhandled exception
trying fix hours, couldn't find solution on internet,i think missing maybe need import more?
i doing tutorial code should work. tutorial: http://www.ibm.com/developerworks/opensource/library/os-weka3/index.html
whole code
import weka.*; import weka.classifiers.trees.j48; import weka.core.*; import weka.classifiers.classifier; import weka.core.instance; import weka.core.instances; import weka.classifiers.functions.linearregression; import weka.classifiers.bayes.naivebayes; public class meni extends activity { public void weka(){ //@attribute housesize numeric attribute a1 = new attribute("housesize", 0); attribute a2 = new attribute("lotsize", 1); attribute a3 = new attribute("bedrooms", 2); attribute a4 = new attribute("granite", 3); attribute a5 = new attribute("bathroom", 4); attribute a6 = new attribute("sellingprice", 5); //arraylist attr = new arraylist(); fastvector attrs = new fastvector(); attrs.addelement(a1); attrs.addelement(a2); attrs.addelement(a3); attrs.addelement(a4); attrs.addelement(a5); attrs.addelement(a6); //@data instance i1 = new denseinstance(6); i1.setvalue(a1, 3529); i1.setvalue(a2, 9191); i1.setvalue(a3, 6); i1.setvalue(a4, 0); i1.setvalue(a5, 0); i1.setvalue(a6, 205000); instance i2 = new denseinstance(6); i2.setvalue(a1, 3247); i2.setvalue(a2, 10061); i2.setvalue(a3, 5); i2.setvalue(a4, 1); i2.setvalue(a5, 1); i2.setvalue(a6, 224900); instance i3 = new denseinstance(6); i3.setvalue(a1, 4032); i3.setvalue(a2, 10150); i3.setvalue(a3, 5); i3.setvalue(a4, 0); i3.setvalue(a5, 1); i3.setvalue(a6, 197900); //set class atribute dataset.setclassindex(dataset.numattributes()-1); //creating model linearregression linearregresion = new linearregression(); linearregresion.buildclassifier(data); //unhandled exception :(
} }
it problem weka.jar library. normal 1 download weka site not working android.now downloaded modified 1 user rjmanrsan: https://github.com/rjmarsan/weka-for-android working :)
Comments
Post a Comment