jshell-scripting

Contains various algorithms for missing values imputation and injection.

License

License

GroupId

GroupId

com.github.fracpete
ArtifactId

ArtifactId

jshell-scripting-weka-package
Last Version

Last Version

2019.4.3
Release Date

Release Date

Type

Type

jar
Description

Description

jshell-scripting
Contains various algorithms for missing values imputation and injection.
Project URL

Project URL

https://github.com/fracpete/jshell-scripting-weka-package
Project Organization

Project Organization

University of Waikato, Hamilton, NZ
Source Code Management

Source Code Management

https://github.com/fracpete/jshell-scripting-weka-package

Download jshell-scripting-weka-package

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.fracpete/jshell-scripting-weka-package/ -->
<dependency>
    <groupId>com.github.fracpete</groupId>
    <artifactId>jshell-scripting-weka-package</artifactId>
    <version>2019.4.3</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.fracpete/jshell-scripting-weka-package/
implementation 'com.github.fracpete:jshell-scripting-weka-package:2019.4.3'
// https://jarcasting.com/artifacts/com.github.fracpete/jshell-scripting-weka-package/
implementation ("com.github.fracpete:jshell-scripting-weka-package:2019.4.3")
'com.github.fracpete:jshell-scripting-weka-package:jar:2019.4.3'
<dependency org="com.github.fracpete" name="jshell-scripting-weka-package" rev="2019.4.3">
  <artifact name="jshell-scripting-weka-package" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.fracpete', module='jshell-scripting-weka-package', version='2019.4.3')
)
libraryDependencies += "com.github.fracpete" % "jshell-scripting-weka-package" % "2019.4.3"
[com.github.fracpete/jshell-scripting-weka-package "2019.4.3"]

Dependencies

compile (2)

Group / Artifact Type Version
nz.ac.waikato.cms.weka : weka-dev jar [3.7.13,)
com.github.fracpete : jshell-scripting jar 0.0.4

test (2)

Group / Artifact Type Version
nz.ac.waikato.cms.weka : weka-dev test-jar [3.7.13,)
junit : junit jar 3.8.2

Project Modules

There are no modules declared in this project.

jshell-scripting-weka-package

Weka package offering scripting via jshell from the GUI chooser, using the jshell-scripting library.

Under the hood, the jshell executable is started with a custom classpath compiled from the current JVM, executing the current content of the editor saved as a temporary script file.

The package requires you to start Weka with Java 9 or later.

Examples

J48

The following code loads the UCI dataset anneal, cross-validates J48 on it and outputs the summary statistics.

import weka.core.Instances;
import weka.core.converters.ConverterUtils.DataSource;
import weka.classifiers.trees.J48;
import weka.classifiers.Evaluation;
import java.util.Random;

Instances data = DataSource.read("/some/where/anneal.arff");
data.setClassIndex(data.numAttributes() - 1);

J48 cls = new J48();
Evaluation eval = new Evaluation(data);
eval.crossValidateModel(cls, data, 10, new Random(1));
System.out.println(eval.toSummaryString());

M5P

In this case, M5P is cross-validated on the UCI dataset bolts:

import weka.core.Instances;
import weka.core.converters.ConverterUtils.DataSource;
import weka.classifiers.trees.M5P;
import weka.classifiers.Evaluation;
import java.util.Random;

Instances data = DataSource.read("/some/where/bolts.arff");
data.setClassIndex(data.numAttributes() - 1);

M5P cls = new M5P();
Evaluation eval = new Evaluation(data);
eval.crossValidateModel(cls, data, 10, new Random(1));
System.out.println(eval.toSummaryString());

LibSVM (package)

Since jshell is a separate process with its own classpath, classes within packages are not visible directly. For getting access to packages, you need to load all Weka packages using WekaPackageManager.loadPackages(false, false, false) and then instantiate classes via the Utils.forName method. Setting options is possible via the setOptions method.

In the following example, the LibSVM classifier (from the LibSVM package) is instantiated and then cross-validated on the UCI dataset anneal:

import weka.core.Instances;
import weka.core.converters.ConverterUtils.DataSource;
import weka.core.OptionHandler;
import weka.core.Utils;
import weka.core.WekaPackageManager;
import weka.classifiers.Evaluation;
import weka.classifiers.Classifier;
import java.util.Random;

WekaPackageManager.loadPackages(false, false, false);

Instances data = DataSource.read("/some/where/anneal.arff");
data.setClassIndex(data.numAttributes() - 1);

Classifier cls = (Classifier) Utils.forName(Classifier.class, "weka.classifiers.functions.LibSVM", new String[0]);
((OptionHandler) cls).setOptions(new String[]{"-K", "2"});
Evaluation eval = new Evaluation(data);
eval.crossValidateModel(cls, data, 10, new Random(1));
System.out.println(eval.toSummaryString());

Releases

Click on one of the following links to download the corresponding Weka package:

Maven

Add the following dependency in your pom.xml to include the package:

    <dependency>
      <groupId>com.github.fracpete</groupId>
      <artifactId>jshell-scripting-weka-package</artifactId>
      <version>2019.4.3</version>
      <type>jar</type>
      <exclusions>
        <exclusion>
          <groupId>nz.ac.waikato.cms.weka</groupId>
          <artifactId>weka-dev</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

Versions

Version
2019.4.3
2018.8.11
2018.7.2