0

I am a total newbie to the weka software and in addition a newbie to java syntax. As a school task we need to write a simple java code for direct usage of neural network classifiers. So I did that but I have troubles compiling in the line data source and line independecies below it says Unhandled Exception. I tried try catch, but it didnt work. What could be the problem and how can I solve it. Thank you in advance.

package ime; 
import weka.core.converters.ConverterUtils.DataSource;
import weka.core.Instances; 
import weka.classifiers.functions.MultilayerPerceptron;
import weka.classifiers.Evaluation;
import java.util.Random;

public class Wekaclass 
{
    public static void main(String [] args) 
    {
        DataSource source = new DataSource("iris.arff");
        Instances instances = source.getDataSet();
        instances.setClassIndex(instances.numAttributes() - 1);

        MultilayerPerceptron mlp = new MultilayerPerceptron();
        mlp.buildClassifier(instances);
        SerializationHelper.write("mlp.model", mlp);
        MultilayerPerceptron mmm = (MultilayerPerceptron)SerializationHelper.read("mlp.model");


        System.out.println("Done training.");
        System.out.println("Testing network...");

        Evaluation eval = nealuation(instances);
        eval.crossValidateModel(mlp, instances, 2, new Random(1));
    }

}   
csabinho
  • 1,579
  • 1
  • 18
  • 28
  • 1
    From your description, it looks like there is an exception being thrown. Please put the stack trace on the question so people can help. – matias.g.rodriguez Nov 17 '19 at 00:07
  • java.io.IOException: No source has been specified at weka.core.converters.ArffLoader.getDataSet(ArffLoader.java:1272) at weka.core.converters.ConverterUtils$DataSource.getDataSet(ConverterUtils.java:264) at Wekaclass.main(Wekaclass.java:12) Exception in thread "main" java.lang.NullPointerException at Wekaclass.main(Wekaclass.java:13) I need the soure codes for Weka jar files but I can't find that – BananasInPyjamas Nov 17 '19 at 13:00

0 Answers0