Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoweka from matlab #35

Closed
dolevr opened this issue Jan 22, 2017 · 6 comments
Closed

Autoweka from matlab #35

dolevr opened this issue Jan 22, 2017 · 6 comments

Comments

@dolevr
Copy link

dolevr commented Jan 22, 2017

I'm trying to integrate autoweka with my code. I'm working from matlab environment and as it seems I get the following error when instantiating AutoWEKAClassifier.

Java exception occurred:
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
	at java.util.ArrayList.rangeCheck(Unknown Source)
	at java.util.ArrayList.get(Unknown Source)
	at autoweka.ApplicabilityTester.getApplicableClassifiers(ApplicabilityTester.java:62)
	at autoweka.ExperimentConstructor.loadClassifiers(ExperimentConstructor.java:336)
	at autoweka.ExperimentConstructor.run(ExperimentConstructor.java:210)
	at autoweka.ExperimentConstructor.buildSingle(ExperimentConstructor.java:158)
	at weka.classifiers.meta.AutoWEKAClassifier.buildClassifier(AutoWEKAClassifier.java:334)

This seem to an issue with instantiating the different weka classifiers even though they are found in the config:

weka.classifiers.bayes.BayesNet.params
weka.classifiers.bayes.NaiveBayes.params
weka.classifiers.bayes.NaiveBayesMultinomial.params
...

Any assistant will be appreciated ....

@larskotthoff
Copy link
Collaborator

How exactly are you using Auto-WEKA? What makes you think it's an issue with instantiating the classifiers?

@dolevr
Copy link
Author

dolevr commented Jan 23, 2017

My mistake I confused it with an earlier problem I had. The issue arises when I try to perform training.

I had some wraper code (Java) for weka classifiers which I used for training/testing classifiers. Next I took the autoweka code and replaced the classifier instantiation with: clf = (Classifier) new AutoWEKAClassifier(); . When training, it causes the exception and stack trace above.

@larskotthoff
Copy link
Collaborator

Could you post a complete example that allows to reproduce the problem please?

@dolevr
Copy link
Author

dolevr commented Jan 23, 2017

Sure:
Java:

public class MyWekaClassifier {
	private Classifier clf;
	public MyWekaClassifier(Config anomalyTagsConfig) throws Error {
		if (anomalyTagsConfig.useAutoWeka) {
			clf = (Classifier) new AutoWEKAClassifier();
		} else {
			initWekaClassifier(anomalyTagsConfig);
		}
		this.anomalyTagsConfig = anomalyTagsConfig;
	};

	public void classifierTrain(double[] inY, double[] inX, int numSamples, int numFeatures) throws Exception {
		Instances trainingData = data2Instances(inY, inX, numSamples, numFeatures);
		clf.buildClassifier(trainingData);
	}
}

The java class compiles to jar and stored in matlab working directory

Matlab code (which calls java):

javaaddpath('.\myJar.jar')
configOBJ = javaObject('com.myproject.Config');
configOBJ.useAutoWeka = config.useAutoWeka;

classifier = javaObject('com.myproject.MyWekaClassifier', configOBJ);
classifier.classifierTrain(yArray, reshape(trainData, [], 1), size(trainData, 2), size(trainData, 1));

I should also mention that I put all the config file in the same directory.

@larskotthoff
Copy link
Collaborator

I can't reproduce the problem. Here's a minimal class that does what you're doing. Running this code works fine for me:

import weka.classifiers.meta.AutoWEKAClassifier;
import weka.classifiers.Classifier;

public class Test {
    private Classifier clf;
	public Test() throws Error {
        clf = (Classifier) new AutoWEKAClassifier();
	};

    public static void main(String[] args) {
        Test test = new Test();
    }
}

@larskotthoff
Copy link
Collaborator

Closing as I can't reproduce the problem. Please reopen if you have a specific example that allows me to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants