You need to add inst_co to your dataset, an instance of the object. The following code should work.
import java.util.ArrayList; import weka.classifiers.Classifier; import weka.core.Attribute; import weka.core.DenseInstance; import weka.core.Instance; import weka.core.Instances; public class QuestionInstanceClassifiy { public static void main(String[] args) { QuestionInstanceClassifiy q = new QuestionInstanceClassifiy(); double result = q.classify(1.0d, 1, 1); System.out.println(result); } private Instance inst_co; public double classify(double lat, double lon, double co) {
You create a data object from instances. Add your instance to this data. After that, you can set your values ββin the instance.
Instances data = new Instances("TestInstances",attributeList,0); inst_co = new DenseInstance(data.numAttributes()); data.add(inst_co);
I suggest getting header information and instance values ββfrom an external file or creating this information only once.
Atilla ozgur
source share