Skip to content

Commit 4a4da28

Browse files
committed
explicit prequential eval
1 parent ed364ed commit 4a4da28

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* This program is free software: you can redistribute it and/or modify
3+
* it under the terms of the GNU General Public License as published by
4+
* the Free Software Foundation, either version 3 of the License, or
5+
* (at your option) any later version.
6+
*
7+
* This program is distributed in the hope that it will be useful,
8+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
* GNU General Public License for more details.
11+
*
12+
* You should have received a copy of the GNU General Public License
13+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
14+
*/
15+
16+
/*
17+
* EvaluatePrequential.java
18+
* Copyright (C) 2024 University of Waikato, Hamilton, NZ
19+
*/
20+
21+
package mekaexamples.classifiers;
22+
23+
import meka.classifiers.incremental.IncrementalEvaluation;
24+
import meka.classifiers.multilabel.incremental.BRUpdateable;
25+
import meka.core.MLUtils;
26+
import meka.core.Result;
27+
import weka.core.Instances;
28+
import weka.core.converters.ConverterUtils.DataSource;
29+
30+
/**
31+
* Evaluates a BRUpdateable Meka classifier prequentially on a dataset supplied by the user.
32+
* <br>
33+
* Expected parameters: &lt;dataset&gt;
34+
* <br>
35+
* Note: The dataset must have been prepared for Meka already.
36+
*
37+
* @author FracPete (fracpete at waikato dot ac dot nz)
38+
*/
39+
public class EvaluatePrequential {
40+
41+
public static void main(String[] args) throws Exception {
42+
if (args.length != 1)
43+
throw new IllegalArgumentException("Required arguments: <dataset>");
44+
45+
System.out.println("Loading data: " + args[0]);
46+
Instances data = DataSource.read(args[0]);
47+
MLUtils.prepareData(data);
48+
49+
System.out.println("Build BRUpdateable classifier");
50+
BRUpdateable classifier = new BRUpdateable();
51+
// further configuration of classifier
52+
Result result = IncrementalEvaluation.evaluateModelPrequentialBasic(classifier, data, 20, 1.0,"PCut1","3");
53+
System.out.println(result);
54+
}
55+
}

0 commit comments

Comments
 (0)