Click here to Skip to main content
14,303,124 members
Rate this:
Please Sign up or sign in to vote.
See more: , +
l am using same code in C# (visual studio 2017) and am have included IKVM.OpenJDK.*.dll (last version )and weka.dll in project.

code:

private void button1_Click(object sender, EventArgs e)
        {
            class_test(); 
        }

const int percentSplit = 60;
        public void class_test()
        {
            string resualt = "";

            try
            {

                 weka.core.Instances insts = new weka.core.Instances(new java.io.FileReader("iris.arff"));



                insts.setClassIndex(insts.numAttributes() - 1); 

                weka.classifiers.Classifier cl = new weka.classifiers.trees.J48();    // choose type of classifer algorithms 

                int trainSize = insts.numInstances() * percentSplit / 100;
                int testSize = insts.numInstances() - trainSize;
                weka.core.Instances train = new weka.core.Instances(insts, 0, trainSize);

                cl.buildClassifier(train);
                int numCorrect = 0;
                for (int i = trainSize; i < insts.numInstances(); i++)
                {
                    weka.core.Instance currentInst = insts.instance(i);
                    double predictedClass = cl.classifyInstance(currentInst);
                    if (predictedClass == insts.instance(i).classValue())
                        numCorrect++;
                }

                System.Console.WriteLine(numCorrect + " out of " + testSize + " correct (" +
                    (double)((double)numCorrect / (double)testSize * 100.0) + "%)");
            }
            catch (java.lang.Exception ex)
            {
                ex.printStackTrace();
            }
        }


But i am getting the following errors:

first :

The type Reader is defined in an assembly that is not referenced. You must add a reference assembly 'vislib, Version=1.0.5000.0, Cultureneutral PublicKey Token-b0315f7f11d50a3a choose 


on the line :

weka.core.Instances insts = new weka.core.Instances(new java.io.FileReader("iris.arff"));


on

new weka.core.Instances


second :

Argument 1 : cannot convert from 'java.io.FileReader' to 'weka.core.instances


on the same line :

weka.core.Instances insts = new weka.core.Instances(new java.io.FileReader("iris.arff"));


on

(new java.io.FileReader("iris.arff"));


What I have tried:

to solve the second error, i tried to add Ikvm.GUN.classpath.dll for another older version as reference, But i am getting the following error:

The type FileReader exists in both 'IKVM.GNU.Classpath, Version= 0.12.0.0, Culture=neutral, PublicKey Token13235d27fcbfff58 and 'IKVM.Open/DK.Core Version=7.2.4630.5, Culture=neutral, PublicKey Token: 13235d271cbfff58


I don't know ,How can I solve this problem?

please, can anyone help me ?
Posted
Comments
BillWoodruff 28-Jul-19 18:56pm
   
I suggest you contact the WEKA project:

https://www.cs.waikato.ac.nz/~ml/weka/help.html
Richard Deeming 30-Jul-19 11:27am
   
What happened when you added a reference to the vislib assembly, as mentioned in the first error message?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100