Skip to content

Commit

Permalink
updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
janvanrijn committed Jul 24, 2017
1 parent 3ac4c7c commit 4095de5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Description.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Maintainer=Jan N. van Rijn <j.n.van.rijn@liacs.leidenuniv.nl>
License=BSD-3-Clause

# Description (required)
Description=Allows sharing Weka experiments on OpenML. Stores for every experiment the classifier, the (serialized) models, the predictions and evaluation measures. Works well together in combination with the openml apiconnector (available on Maven Central, artifact id org.openml.apiconnector). If you found this package useful, please cite: J. N. van Rijn, Massively Collaborative Machine Learning, Leiden University, 2016.
Description=Allows sharing Weka experiments on OpenML. Stores for every experiment the classifier, the (serialized) models, the predictions and evaluation measures. Works well in combination with the openml apiconnector (available on Maven Central, artifact id org.openml.apiconnector). If you found this package useful, please cite: J. N. van Rijn, Massively Collaborative Machine Learning, Leiden University, 2016.

# Package URL for obtaining the package archive (required)
PackageURL=https://github.com/openml/openml-weka/releases/download/openmlweka-0.9.5/OpenmlWeka.zip
Expand Down
36 changes: 27 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,34 @@ Package for uploading Weka experiments to OpenML.

Code example, download 100 (pre-selected) datasets and execute a REPTree on these.

```
```java
public static void runTasksAndUpload() throws Exception {
OpenmlConnector openml = new OpenmlConnector("<FILL_IN_OPENML_API_KEY>");
Study s = openml.studyGet("OpenML100", "tasks");
Classifier tree = new REPTree();
for (Integer taskId : s.getTasks()) {
Task t = openml.taskGet(taskId);
Instances d = InstancesHelper.getDatasetFromTask(openml, t);
int runId = RunOpenmlJob.executeTask(openml, new WekaConfig(), taskId, tree);
// Fill in the API key (obtainable from your OpenML profile)
String apikey = "d488d8afd93b32331cf6ea9d7003d4c3";

// The WekaConfig module gives us the possibilities to enable or disable various Weka Specific options
WekaConfig config = new WekaConfig();

// Instantiate the OpenmlConnector object
// requires artifact org.openml.apiconnector (version 1.0.14) from Maven central
OpenmlConnector openml = new OpenmlConnector(apikey);

// Download the OpenML object containing the `OpenML100' benchmark set
Study s = openml.studyGet("OpenML100", "tasks");

// Loop over all the tasks
for (Integer taskId : s.getTasks()) {
// create a Weka classifier to run on the task
Classifier tree = new NaiveBayes();

// execute the task (can take a while, depending on the classifier / dataset combination)
int runId = RunOpenmlJob.executeTask(openml, config, taskId, tree);

// After several minutes, the evaluation measures will be available on the server
System.out.println("Available on " + openml.getApiUrl() + "run/" + runId);

// Download the run from the server:
Run run = openml.runGet(runId);
}
}
}
```
5 changes: 4 additions & 1 deletion src/main/java/org/openml/weka/experiment/RunOpenmlJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE

import javax.swing.DefaultListModel;

import org.openml.apiconnector.algorithms.Conversion;
import org.openml.apiconnector.io.OpenmlConnector;
import org.openml.apiconnector.xml.Task;
import org.openml.weka.algorithm.WekaConfig;
Expand Down Expand Up @@ -87,7 +88,9 @@ public static int executeTask(OpenmlConnector openml, WekaConfig config, Integer

// set task
DefaultListModel<Task> tasks = new DefaultListModel<Task>();
tasks.add(0, openml.taskGet(task_id));
Task task = openml.taskGet(task_id);
Conversion.log("OK", "TaskGet", "Downloaded " + task.getTask_name());
tasks.add(0, task);
exp.setTasks(tasks);

// run the stuff
Expand Down

0 comments on commit 4095de5

Please sign in to comment.