Tom
Tom

Reputation: 11

Weka - Can't find a permissible class

I'm integrating Weka into a plug-in I'm writing for another application. I included weka.jar in my class path and for the most part, things seem to be working well. Unfortunately, when I get to the point of changing the options for some classifiers, I run into problems specific to being unable to find certain classes. For example, when I try to change the name of the classifier in the AdaBoost options, I get an error that ends like so:

java.lang.Exception: Can't find a permissible class called: weka.classifiers.bayes.BayesNet
Model options set to: -P 50 -S 1 -I 10 -W weka.classifiers.bayes.BayesNet
    at weka.core.ResourceUtils.forName(ResourceUtils.java:84)
    at weka.core.Utils.forName(Utils.java:1080)
    at weka.classifiers.AbstractClassifier.forName(AbstractClassifier.java:91)
    at weka.classifiers.SingleClassifierEnhancer.setOptions(SingleClassifierEnhancer.java:108)
    at weka.classifiers.IteratedSingleClassifierEnhancer.setOptions(IteratedSingleClassifierEnhancer.java:115)
    at weka.classifiers.RandomizableIteratedSingleClassifierEnhancer.setOptions(RandomizableIteratedSingleClassifierEnhancer.java:93)
    at weka.classifiers.meta.AdaBoostM1.setOptions(AdaBoostM1.java:375)

I'm thinking that this might have something to do with me using the JAR in an OSGi bundle, but I'm not sure. Any ideas? Other than this issue, I'm able to train these classifiers just fine using the default options for them.

Thanks.

Upvotes: 1

Views: 344

Answers (1)

Mikhail  Gerasimov
Mikhail Gerasimov

Reputation: 67

Solve this problem via set all parameters via setters. This problem when you use like this

        BayesNet processes = new BayesNet();
        String options = "-D -Q weka.classifiers.bayes.net.search.local.K2 -- -P 1 -S BAYES -E weka.classifiers.bayes.net.estimate.SimpleEstimator -- -A 0.5";
        processes.setOptions(weka.core.Utils.splitOptions(options));

Change set all param like this.(Here not all option, small example)

        BayesNet processes = new BayesNet();
        SimpleEstimator newBayesNetEstimator = new SimpleEstimator();
        newBayesNetEstimator.setAlpha(0.5);
        processes.setEstimator(newBayesNetEstimator);

Upvotes: 1

Related Questions