Problem using classifiers.evaluation.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem using classifiers.evaluation.

David
Hi there,
  I wanted to play with the Evaluation API to for exapple to perform a
tenfold and see the accuracy stats. However, the very simple code below (and
all similar) does not compile. There is an error message saying "The
constructor Evaluation(Instances) is undefined". Another one is saying "The
method crossValidateModel(...) is undefined for the type Evaluation".

I am assuming it is using the wrong version of classifiers.evaluation.

Any help?

See below the code,
Thanks

import weka.core.Instances;
import java.util.Random;
import weka.core.converters.ConverterUtils.DataSource;
import weka.classifiers.trees.J48;
import weka.classifiers.Classifier;
import weka.classifiers.evaluation.*;



public class Evaluation{
        public static void main(String args[]) throws Exception{
               

       
                //load datasets
                                DataSource source = new DataSource("C:/Program
Files/Weka-3-8/data/breast-cancerKnown.arff");
                                Instances data = source.getDataSet();
                                Classifier cls = new J48();
                                Evaluation eval = new Evaluation(data);
                                Random rand = new Random(1);  // using seed = 1
                                int folds = 10;
                                eval.crossValidateModel(cls, data, folds, rand);
                                System.out.println(eval.toSummaryString());

        }
}

Exception in thread "main" java.lang.Error: Unresolved compilation problems:
        The constructor Evaluation(Instances) is undefined
        The method crossValidateModel(Classifier, Instances, int, Random) is
undefined for the type Evaluation
        The method toSummaryString() is undefined for the type Evaluation

        at Evaluation.main(Evaluation.java:32)





--
Sent from: https://weka.8497.n7.nabble.com/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to: To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit
https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Problem using classifiers.evaluation.

Peter Reutemann-3
On January 25, 2020 12:41:14 AM GMT+13:00, David <[hidden email]> wrote:

>Hi there,
>  I wanted to play with the Evaluation API to for exapple to perform a
>tenfold and see the accuracy stats. However, the very simple code below
>(and
>all similar) does not compile. There is an error message saying "The
>constructor Evaluation(Instances) is undefined". Another one is saying
>"The
>method crossValidateModel(...) is undefined for the type Evaluation".
>
>I am assuming it is using the wrong version of classifiers.evaluation.
>
>Any help?
>
>See below the code,
>Thanks
>
>import weka.core.Instances;
>import java.util.Random;
>import weka.core.converters.ConverterUtils.DataSource;
>import weka.classifiers.trees.J48;
>import weka.classifiers.Classifier;
>import weka.classifiers.evaluation.*;
>
>
>
>public class Evaluation{
> public static void main(String args[]) throws Exception{
>
>
>
> //load datasets
> DataSource source = new DataSource("C:/Program
>Files/Weka-3-8/data/breast-cancerKnown.arff");
> Instances data = source.getDataSet();
> Classifier cls = new J48();
> Evaluation eval = new Evaluation(data);
> Random rand = new Random(1);  // using seed = 1
> int folds = 10;
> eval.crossValidateModel(cls, data, folds, rand);
> System.out.println(eval.toSummaryString());
>
> }
>}
>
>Exception in thread "main" java.lang.Error: Unresolved compilation
>problems:
> The constructor Evaluation(Instances) is undefined
> The method crossValidateModel(Classifier, Instances, int, Random) is
>undefined for the type Evaluation
> The method toSummaryString() is undefined for the type Evaluation
>
> at Evaluation.main(Evaluation.java:32)
>
>
>
>
>
>--
>Sent from: https://weka.8497.n7.nabble.com/
>_______________________________________________
>Wekalist mailing list -- [hidden email]
>Send posts to: To unsubscribe send an email to
>[hidden email]
>To subscribe, unsubscribe, etc., visit
>https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
>List etiquette:
>http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html

Your class is called Evaluation, which takes precedence over the Weka class. Rename it to something else, like EvaluationExample.

Cheers, Peter
--
Peter Reutemann
Dept. of Computer Science
University of Waikato, NZ
+64 (7) 858-5174
http://www.cms.waikato.ac.nz/~fracpete/
http://www.data-mining.co.nz/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to: To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit
https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: Problem using classifiers.evaluation.

David
Thanks, it worked. What were the odds????



--
Sent from: https://weka.8497.n7.nabble.com/
_______________________________________________
Wekalist mailing list -- [hidden email]
Send posts to: To unsubscribe send an email to [hidden email]
To subscribe, unsubscribe, etc., visit
https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html