Home > Enterprise >  Problem Python-weka-wrapper3 with GridSearch
Problem Python-weka-wrapper3 with GridSearch

Time:10-22

Hi i'm haveing problems with this code, i'm trying to make a gridsearch for optimize some properties

from weka.classifiers import GridSearch

grid = GridSearch(options=["-sample-size", "100.0", "-traversal", "ROW-WISE", "-num-slots", "1", "-S", "1"])
grid.evaluation = "CC"
grid.y = {"property": "kernel.gamma", "min": -3.0, "max": 3.0, "step": 1.0, "base": 10.0, "expression": "pow(BASE,I)"}
grid.x = {"property": "C", "min": -3.0, "max": 3.0, "step": 1.0, "base": 10.0, "expression": "pow(BASE,I)"}
cls = Classifier(
    classname="weka.classifiers.functions.SMOreg",
    options=["-K", "weka.classifiers.functions.supportVector.RBFKernel"])
grid.classifier = cls
grid.build_classifier(train)
print("Model:\n"   str(grid))
print("\nBest setup:\n"   grid.best.to_commandline())

I'm haveing this problems:

Failed to get class weka.classifiers.meta.GridSearch

Exception in thread "Thread-0" java.lang.NoClassDefFoundError: weka.classifiers.meta.GridSearch

Caused by: java.lang.ClassNotFoundException: weka.classifiers.meta.GridSearch
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
/tmp/ipykernel_11771/802912337.py in <module>
      9     options=["-K", "weka.classifiers.functions.supportVector.RBFKernel"])
     10 grid.classifier = cls
---> 11 grid.build_classifier(train)
     12 print("Model:\n"   str(grid))
     13 print("\nBest setup:\n"   grid.best.to_commandline())

NameError: name 'train' is not defined


Any sugestions?

CodePudding user response:

The GridSearch and MultiSearch meta-classifiers are available through Weka packages, they are not part of the core Weka distribution. In order to use them you need to install the respective packages.

If you want use pww3 for installing/managing packages, then take a look at the examples on packages.

  • Related