Waikato / moa

MOA is an open source framework for Big Data stream mining. It includes a collection of machine learning algorithms (classification, regression, clustering, outlier detection, concept drift detection and recommender systems) and tools for evaluation.
http://moa.cms.waikato.ac.nz/
GNU General Public License v3.0
610 stars 353 forks source link

How to implement Cramer's test in Java? - Cramer - 'ArrayStoreException' #152

Closed betrw closed 3 years ago

betrw commented 5 years ago

Submitting the parameters to the method:

Cramer c = new Cramer(); c.cramerTest1(CR1, CR2); pi.CremerTValue = ?

fails with the error 'ArrayStoreException' at the second line after passing the parameters.

I tried:

List<List>CR1 = new ArrayList<List>(); List<List>CR2 = new ArrayList<List>();

CR1.add(First); CR2.add(Second);

--or--

List<List>CR1 = Arrays.asList(First); List<List>CR2 = Arrays.asList(Second);

Both declarations failed.

First and Second are both of the type ArrayList with a size of 177 items. CR1 and CR2 have one item that contain 177 values.

How can I implement the two sample Cramer-Mises T test?

betrw commented 5 years ago

I guess the two samples Cramer test is the Anderson-Darling-Test?

abifet commented 5 years ago

@pmgj: can you help on this? Thanks!

pmgj commented 5 years ago

Hi,

This cramer test works comparing the attribute values of a List of Instance elements. An example that can read values from ARFF files is:

    List<Instance> x = Cramer.fileToInstances("test1-x.arff");
    List<Instance> y = Cramer.fileToInstances("test1-y.arff");
    Cramer c = new Cramer();
    Cramer.CramerTest ct = c.cramerTest(x, y);
    System.out.println("p Value.: " + ct.pValue);
    System.out.println("Critical value: " + ct.critValue);
    System.out.println("Statistic: " + ct.statistic);

The CramerTest is only used inside the class. I probably had to make it private. This Java implementation was based on the Cramer test source code available in the R statistic tool.

betrw commented 5 years ago

Thanks a lot.