[...]
> ModuleNotFoundError: No module named 'javabridge._javabridge''
>
> I've added the path of the jdk into JAVA_HOME and inserted at the end of bashrc
>
> This code works correctly in Colab, however, in local it doesn't. I do know that Jupyter is not the appropriated environment, however, after re-running the kernel, it should work.
>
> I don't know what is the problem.
Rather than trying a complex example, it is best to start small again.
Here are the steps on my Linux Mint machine to set up and run a
Jupyter Notebook:
1. set up a new virtual environment
virtualenv -p /usr/bin/python3 pww3
./pww3/bin/pip install numpy
./pww3/bin/pip install javabridge
./pww3/bin/pip install python-weka-wrapper3
./pww3/bin/pip install jupyter
2. Start up Jupyter notebook and create a new Python3 notebook
./pww3/bin/jupyter-notebook
3. Enter this code in a cell and run it (adapt the path to the nominal
dataset, of course):
import weka.core.jvm as jvm
from weka.core.converters import load_any_file
from weka.classifiers import Classifier
jvm.start()
data = load_any_file("/some/where/iris.arff")
data.class_is_last()
cls = Classifier(classname="weka.classifiers.trees.J48")
cls.build_classifier(data)
print(cls)
jvm.stop()
Which works fine on my machine.
The output of "./pww3/bin/pip freeze" is attached.
Cheers, Peter
--
Peter Reutemann
Dept. of Computer Science
University of Waikato, NZ
+64 (7) 858-5174 (office)
+64 (7) 577-5304 (home office)
http://www.cms.waikato.ac.nz/~fracpete/
http://www.data-mining.co.nz/