Home>
I would like to read and predict the training data and test data repeatedly using

for.
However, I don't know what to do because the data doesn't load properly.
The data to be read is 'learning_hoge_i.csv' (i = 0 ~ 99).
Thank you in advance.

Applicable source code
import weka.core.jvm as jvm
from weka.core.converters import Loader
from weka.classifiers import Classifier
from weka.classifiers import Evaluation
import numpy as np
import pandas as pd
#Specify file name
filename = 'hoge'
#promise?
jvm.start ()
pred = []
for i in range (100):
    #Load learning data
    loader = Loader (classname = 'weka.core.converters.CSVLoader')
    learning = loader.load_file ('learning_ {0} _ {1} .csv'.format (filename, i))
    learning.class_is_first ()
    #Load test data
    loader = Loader (classname = "weka.core.converters.CSVLoader")
    test = loader.load_file ('test_ {0} _ {1} .csv'.format (filename, i))
    test.class_is_first ()
    #Model building
    cls = Classifier (classname = "weka.classifiers.trees.M5P")
    cls.build_classifier (learning)
    #Prediction by built model
    evaluation = Evaluation (test)
    evl = evaluation.test_model (cls, test)
    pred.append (evl [0])
df = pd.DataFrame (pred)
df = df.T
df.to_csv ('test.csv')
Error message
JavaException Traceback (most recent call last)
<ipython-input-8-6ea222f7efc9>in<module>
     18 # Load learning data
     19 loader = Loader (classname = 'weka.core.converters.CSVLoader')
--->20 learning = loader.load_file ('learning_ {0} _ {1} .csv'.format (filename, i))
     21 learning.class_is_first ()
     22 # Load test data
~ \ Anaconda3 \ envs \ tensorflow \ lib \ site-packages \ weka \ core \ converters.py in load_file (self, dfile, incremental)
     86 return self.structure
     87 else:
--->88 return Instances (javabridge.call (self.jobject, "getDataSet", "() Lweka/core/Instances;"))
     89
     90 def load_url (self, url, incremental = False):
~ \ Anaconda3 \ envs \ tensorflow \ lib \ site-packages \ javabridge \ jutil.py in call (o, method_name, sig, * args)
    885 ret_sig = sig [sig.find (')') + 1:]
    886 nice_args = get_nice_args (args, args_sig)
->887 result = fn (* nice_args)
    888 x = env.exception_occurred ()
    889 if x is not None:
~ \ Anaconda3 \ envs \ tensorflow \ lib \ site-packages \ javabridge \ jutil.py in fn (* args)
    852 x = env.exception_occurred ()
    853 if x is not None:
->854 raise JavaException (x)
    855 return result
    856 else:
JavaException: 56 Problem encountered on line: 2