Full Code of yinlou/mltk for AI

master f50c42986fdd cached
194 files
810.9 KB
245.2k tokens
1520 symbols
1 requests
Download .txt
Showing preview only (874K chars total). Download the full file or copy to clipboard to get everything.
Repository: yinlou/mltk
Branch: master
Commit: f50c42986fdd
Files: 194
Total size: 810.9 KB

Directory structure:
gitextract_ke00o21_/

├── .gitignore
├── LICENSE
├── README.md
├── pom.xml
└── src/
    ├── main/
    │   └── java/
    │       └── mltk/
    │           ├── cmdline/
    │           │   ├── Argument.java
    │           │   ├── CmdLineParser.java
    │           │   ├── options/
    │           │   │   ├── HoldoutValidatedLearnerOptions.java
    │           │   │   ├── HoldoutValidatedLearnerWithTaskOptions.java
    │           │   │   ├── LearnerOptions.java
    │           │   │   ├── LearnerWithTaskOptions.java
    │           │   │   └── package-info.java
    │           │   └── package-info.java
    │           ├── core/
    │           │   ├── Attribute.java
    │           │   ├── BinnedAttribute.java
    │           │   ├── Bins.java
    │           │   ├── Copyable.java
    │           │   ├── DenseVector.java
    │           │   ├── Instance.java
    │           │   ├── Instances.java
    │           │   ├── NominalAttribute.java
    │           │   ├── NumericalAttribute.java
    │           │   ├── Sampling.java
    │           │   ├── SparseVector.java
    │           │   ├── Vector.java
    │           │   ├── Writable.java
    │           │   ├── io/
    │           │   │   ├── AttributesReader.java
    │           │   │   ├── InstancesReader.java
    │           │   │   ├── InstancesWriter.java
    │           │   │   └── package-info.java
    │           │   ├── package-info.java
    │           │   └── processor/
    │           │       ├── Discretizer.java
    │           │       ├── InstancesSplitter.java
    │           │       ├── OneHotEncoder.java
    │           │       └── package-info.java
    │           ├── feature/
    │           │   └── selection/
    │           │       ├── BackwardElimination.java
    │           │       └── package-info.java
    │           ├── predictor/
    │           │   ├── BaggedEnsemble.java
    │           │   ├── BaggedEnsembleLearner.java
    │           │   ├── BoostedEnsemble.java
    │           │   ├── Classifier.java
    │           │   ├── Ensemble.java
    │           │   ├── Family.java
    │           │   ├── HoldoutValidatedLearner.java
    │           │   ├── Learner.java
    │           │   ├── LinkFunction.java
    │           │   ├── Predictor.java
    │           │   ├── ProbabilisticClassifier.java
    │           │   ├── Regressor.java
    │           │   ├── evaluation/
    │           │   │   ├── AUC.java
    │           │   │   ├── ConvergenceTester.java
    │           │   │   ├── Error.java
    │           │   │   ├── Evaluator.java
    │           │   │   ├── LogLoss.java
    │           │   │   ├── LogisticLoss.java
    │           │   │   ├── MAE.java
    │           │   │   ├── Metric.java
    │           │   │   ├── MetricFactory.java
    │           │   │   ├── Predictor.java
    │           │   │   ├── RMSE.java
    │           │   │   ├── SimpleMetric.java
    │           │   │   └── package-info.java
    │           │   ├── function/
    │           │   │   ├── Array1D.java
    │           │   │   ├── Array2D.java
    │           │   │   ├── BaggedLineCutter.java
    │           │   │   ├── BivariateFunction.java
    │           │   │   ├── CHistogram.java
    │           │   │   ├── CompressionUtils.java
    │           │   │   ├── CubicSpline.java
    │           │   │   ├── EnsembledLineCutter.java
    │           │   │   ├── Function1D.java
    │           │   │   ├── Function2D.java
    │           │   │   ├── Histogram2D.java
    │           │   │   ├── LineCutter.java
    │           │   │   ├── LinearFunction.java
    │           │   │   ├── SquareCutter.java
    │           │   │   ├── SubagSequence.java
    │           │   │   ├── SubaggedLineCutter.java
    │           │   │   ├── UnivariateFunction.java
    │           │   │   └── package-info.java
    │           │   ├── gam/
    │           │   │   ├── DenseDesignMatrix.java
    │           │   │   ├── GA2MLearner.java
    │           │   │   ├── GAM.java
    │           │   │   ├── GAMLearner.java
    │           │   │   ├── GAMUtils.java
    │           │   │   ├── SPLAMLearner.java
    │           │   │   ├── ScorecardModelLearner.java
    │           │   │   ├── SparseDesignMatrix.java
    │           │   │   ├── interaction/
    │           │   │   │   ├── FAST.java
    │           │   │   │   └── package-info.java
    │           │   │   ├── package-info.java
    │           │   │   └── tool/
    │           │   │       ├── Diagnostics.java
    │           │   │       ├── Visualizer.java
    │           │   │       └── package-info.java
    │           │   ├── glm/
    │           │   │   ├── ElasticNetLearner.java
    │           │   │   ├── GLM.java
    │           │   │   ├── GLMLearner.java
    │           │   │   ├── GLMOptimUtils.java
    │           │   │   ├── GroupLassoLearner.java
    │           │   │   ├── LassoLearner.java
    │           │   │   ├── RidgeLearner.java
    │           │   │   └── package-info.java
    │           │   ├── io/
    │           │   │   ├── PredictorReader.java
    │           │   │   ├── PredictorWriter.java
    │           │   │   └── package-info.java
    │           │   ├── package-info.java
    │           │   └── tree/
    │           │       ├── DecisionTable.java
    │           │       ├── DecisionTableLearner.java
    │           │       ├── RTree.java
    │           │       ├── RTreeLearner.java
    │           │       ├── RegressionTree.java
    │           │       ├── RegressionTreeLeaf.java
    │           │       ├── RegressionTreeLearner.java
    │           │       ├── TreeInteriorNode.java
    │           │       ├── TreeLearner.java
    │           │       ├── TreeNode.java
    │           │       ├── ensemble/
    │           │       │   ├── BaggedRTrees.java
    │           │       │   ├── BoostedDTables.java
    │           │       │   ├── BoostedRTrees.java
    │           │       │   ├── RTreeList.java
    │           │       │   ├── TreeEnsembleLearner.java
    │           │       │   ├── ag/
    │           │       │   │   ├── AdditiveGroves.java
    │           │       │   │   ├── AdditiveGrovesLearner.java
    │           │       │   │   └── package-info.java
    │           │       │   ├── brt/
    │           │       │   │   ├── BDT.java
    │           │       │   │   ├── BRT.java
    │           │       │   │   ├── BRTLearner.java
    │           │       │   │   ├── BRTUtils.java
    │           │       │   │   ├── LADBoostLearner.java
    │           │       │   │   ├── LSBoostLearner.java
    │           │       │   │   ├── LogitBoostLearner.java
    │           │       │   │   ├── RobustDecisionTableLearner.java
    │           │       │   │   ├── RobustRegressionTreeLearner.java
    │           │       │   │   └── package-info.java
    │           │       │   ├── package-info.java
    │           │       │   └── rf/
    │           │       │       ├── RandomForest.java
    │           │       │       ├── RandomForestLearner.java
    │           │       │       ├── RandomRegressionTreeLearner.java
    │           │       │       └── package-info.java
    │           │       └── package-info.java
    │           └── util/
    │               ├── ArrayUtils.java
    │               ├── Element.java
    │               ├── MathUtils.java
    │               ├── OptimUtils.java
    │               ├── Permutation.java
    │               ├── Queue.java
    │               ├── Random.java
    │               ├── Stack.java
    │               ├── StatUtils.java
    │               ├── UFSets.java
    │               ├── VectorUtils.java
    │               ├── package-info.java
    │               └── tuple/
    │                   ├── DoublePair.java
    │                   ├── IntDoublePair.java
    │                   ├── IntDoublePairComparator.java
    │                   ├── IntPair.java
    │                   ├── IntTriple.java
    │                   ├── LongDoublePair.java
    │                   ├── LongDoublePairComparator.java
    │                   ├── LongPair.java
    │                   ├── Pair.java
    │                   ├── Triple.java
    │                   └── package-info.java
    └── test/
        └── java/
            └── mltk/
                ├── core/
                │   ├── BinsTest.java
                │   ├── InstancesTestHelper.java
                │   ├── io/
                │   │   ├── AttributesReaderTest.java
                │   │   └── InstancesReaderTest.java
                │   └── processor/
                │       ├── DiscretizerTest.java
                │       └── InstancesSplitterTest.java
                ├── predictor/
                │   ├── evaluation/
                │   │   ├── AUCTest.java
                │   │   ├── ConvergenceTesterTest.java
                │   │   ├── ErrorTest.java
                │   │   ├── LogLossTest.java
                │   │   ├── LogisticLossTest.java
                │   │   ├── MAETest.java
                │   │   ├── MetricFactoryTest.java
                │   │   └── RMSETest.java
                │   ├── glm/
                │   │   └── GLMTest.java
                │   └── tree/
                │       ├── DecisionTableLearnerTest.java
                │       ├── DecisionTableTest.java
                │       ├── DecisionTableTestHelper.java
                │       ├── RegressionTreeLearnerTest.java
                │       ├── RegressionTreeTest.java
                │       ├── RegressionTreeTestHelper.java
                │       └── ensemble/
                │           ├── BoostedDTablesTest.java
                │           ├── BoostedRTreesTest.java
                │           └── brt/
                │               ├── BDTTest.java
                │               ├── BRTTest.java
                │               ├── BRTUtilsTest.java
                │               └── LogitBoostLearnerTest.java
                └── util/
                    ├── ArrayUtilsTest.java
                    ├── MathUtilsTest.java
                    ├── OptimUtilsTest.java
                    ├── StatUtilsTest.java
                    └── VectorUtilsTest.java

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
*~
*.swp

*.class

# osx
.DS_Store

# Eclipse build artifacts
.project
.classpath

# Maven
target

build/
**/build/
classes

# IntelliJ
.idea/
*.iml
*.ipr
*.iws
**/*.iml
out/
**/.classpath
**/.project
.settings/
**/.settings/



================================================
FILE: LICENSE
================================================
Copyright (c) 2012-2019, Yin Lou
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of the organization nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

================================================
FILE: README.md
================================================
# Machine Learning Tool Kit

MLTK is a collection of various supervised machine learning algorithms, which is designed for directly training models and further development. For questions or suggestions with the code, please email <a href="mailto:machinelearningtoolkit@gmail.com">machinelearningtoolkit@gmail.com</a>. 

See [wiki](https://github.com/yinlou/mltk/wiki) for full documentation, examples and other information.


================================================
FILE: pom.xml
================================================
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.github.yinlou</groupId>
  <artifactId>mltk</artifactId>
  <version>0.1.1-SNAPSHOT</version>

  <name>mltk</name>
  <description>Machine Learning Tool Kit</description>
  <url>https://github.com/yinlou/mltk</url>

  <licenses>
    <license>
      <name>BSD 3-Clause</name>
      <url>https://opensource.org/licenses/BSD-3-Clause</url>
    </license>
  </licenses>

   <developers>
    <developer>
      <name>Yin Lou</name>
      <email>machinelearningtoolkit@gmail.com</email>
    </developer>
  </developers>

  <scm>
    <connection>scm:git:git://github.com/yinlou/mltk.git</connection>
    <developerConnection>scm:git:ssh://github.com:yinlou/mltk.git</developerConnection>
    <url>https://github.com/yinlou/mltk.git</url>
  </scm>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>

  <profiles>
    <profile>
      <id>doclint-java8-disable</id>
      <activation>
        <jdk>[1.8,)</jdk>
      </activation>
      <properties>
        <javadoc.opts>-Xdoclint:none</javadoc.opts>
      </properties>
    </profile>
  </profiles>

  <distributionManagement>
    <snapshotRepository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
  </distributionManagement>

  <build>
    <plugins>
      <plugin>
        <groupId>org.sonatype.plugins</groupId>
        <artifactId>nexus-staging-maven-plugin</artifactId>
        <version>1.6.7</version>
        <extensions>true</extensions>
        <configuration>
          <serverId>ossrh</serverId>
          <nexusUrl>https://oss.sonatype.org/</nexusUrl>
          <autoReleaseAfterClose>true</autoReleaseAfterClose>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.5.1</version>
        <configuration>
          <showDeprecation>true</showDeprecation>
          <source>${maven.compiler.source}</source>
          <target>${maven.compiler.target}</target> 
        </configuration>
      </plugin>
      <plugin>
      <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>2.2.1</version>
        <executions>
          <execution>
           <id>attach-sources</id>
            <goals>
              <goal>jar-no-fork</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>2.10.3</version>
        <configuration>
          <source>8</source>
          <doctitle>Machine Learning Tool Kit ${project.version} API</doctitle>
          <windowtitle>Machine Learning Tool Kit ${project.version} API</windowtitle>
          <additionalparam>${javadoc.opts}</additionalparam>
        </configuration>
        <executions>
          <execution>
            <id>attach-javadocs</id>
            <phase>package</phase>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
      <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-gpg-plugin</artifactId>
        <version>1.5</version>
        <executions>
         <execution>
            <id>sign-artifacts</id>
            <phase>verify</phase>
            <goals>
             <goal>sign</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.13.1</version>
    </dependency>
  </dependencies>

  <repositories>
  </repositories>

</project>


================================================
FILE: src/main/java/mltk/cmdline/Argument.java
================================================
package mltk.cmdline;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

/**
 * Command line argument.
 * 
 * @author Yin Lou
 * 
 */
@Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Argument {

	/**
	 * Name of this argument.
	 * 
	 * @return the name of this argument.
	 */
	String name() default "";

	/**
	 * Description of this argument.
	 * 
	 * @return the description of this argument.
	 */
	String description() default "";

	/**
	 * Whether this argument is required.
	 * 
	 * @return {@code true} if the argument is required.
	 */
	boolean required() default false;

}


================================================
FILE: src/main/java/mltk/cmdline/CmdLineParser.java
================================================
package mltk.cmdline;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Class for command line parser.
 * 
 * @author Yin Lou
 * 
 */
public class CmdLineParser {

	private String name;
	private Object obj;

	private List<Argument> argList;
	private List<Field> fieldList;

	/**
	 * Constructor.
	 * 
	 * @param clazz the class object.
	 * @param obj the object.
	 */
	public CmdLineParser(Class<?> clazz, Object obj) {
		this.name = clazz.getCanonicalName();
		this.obj = obj;

		argList = new ArrayList<>();
		fieldList = new ArrayList<>();
		
		processFields(obj.getClass().getFields());
		processFields(obj.getClass().getDeclaredFields());
	}

	/**
	 * Parses the command line arguments.
	 * 
	 * @param args the command line arguments.
	 * @throws IllegalArgumentException
	 * @throws IllegalAccessException
	 */
	public void parse(String[] args) throws IllegalArgumentException, IllegalAccessException {
		if (args.length % 2 != 0) {
			throw new IllegalArgumentException();
		}
		Map<String, String> map = new HashMap<>();
		for (int i = 0; i < args.length; i += 2) {
			map.put(args[i], args[i + 1]);
		}
		for (int i = 0; i < argList.size(); i++) {
			Field field = fieldList.get(i);
			Argument arg = argList.get(i);
			String value = map.get(arg.name());
			if (value != null) {
				Class<? extends Object> fclass = field.getType();
				field.setAccessible(true);
				if (fclass == String.class) {
					field.set(obj, value);
				} else if (fclass == int.class) {
					field.setInt(obj, Integer.parseInt(value));
				} else if (fclass == double.class) {
					field.setDouble(obj, Double.parseDouble(value));
				} else if (fclass == float.class) {
					field.setFloat(obj, Float.parseFloat(value));
				} else if (fclass == boolean.class) {
					field.setBoolean(obj, Boolean.parseBoolean(value));
				} else if (fclass == long.class) {
					field.setLong(obj, Long.parseLong(value));
				} else if (fclass == char.class) {
					field.setChar(obj, value.charAt(0));
				}
			} else if (arg.required()) {
				throw new IllegalArgumentException();
			}
		}
	}

	/**
	 * Prints the generated usage.
	 */
	public void printUsage() {
		StringBuilder sb = new StringBuilder();
		sb.append("Usage: ").append(name).append("\n");

		StringBuilder required = new StringBuilder();
		StringBuilder optional = new StringBuilder();

		for (Argument arg : argList) {
			if (arg.required()) {
				required.append(arg.name()).append("\t").append(arg.description()).append("\n");
			} else {
				optional.append("[").append(arg.name()).append("]\t").append(arg.description()).append("\n");
			}
		}

		sb.append(required).append(optional);
		System.err.println(sb.toString());
	}
	
	private void processFields(Field[] fields) {
		for (Field field : fields) {
			Argument argument = field.getAnnotation(Argument.class);
			if (argument != null) {
				fieldList.add(field);
				argList.add(argument);
			}
		}
	}

}


================================================
FILE: src/main/java/mltk/cmdline/options/HoldoutValidatedLearnerOptions.java
================================================
package mltk.cmdline.options;

import mltk.cmdline.Argument;

public class HoldoutValidatedLearnerOptions extends LearnerOptions {

	@Argument(name = "-v", description = "valid set path")
	public String validPath = null;
	
	@Argument(name = "-e", description = "evaluation metric (default: default metric of task)")
	public String metric = null;
	
	@Argument(name = "-S", description = "convergence criteria (default: -1) ")
	public String cc = "-1";

}


================================================
FILE: src/main/java/mltk/cmdline/options/HoldoutValidatedLearnerWithTaskOptions.java
================================================
package mltk.cmdline.options;

import mltk.cmdline.Argument;

public class HoldoutValidatedLearnerWithTaskOptions extends HoldoutValidatedLearnerOptions {

	@Argument(name = "-g", description = "task between classification (c) and regression (r) (default: r)")
	public String task = "r";
	
}


================================================
FILE: src/main/java/mltk/cmdline/options/LearnerOptions.java
================================================
package mltk.cmdline.options;

import mltk.cmdline.Argument;

public class LearnerOptions {

	@Argument(name = "-r", description = "attribute file path")
	public String attPath = null;

	@Argument(name = "-t", description = "train set path", required = true)
	public String trainPath = null;

	@Argument(name = "-o", description = "output model path")
	public String outputModelPath = null;
	
	@Argument(name = "-V", description = "verbose (default: true)")
	public boolean verbose = true;
	
}


================================================
FILE: src/main/java/mltk/cmdline/options/LearnerWithTaskOptions.java
================================================
package mltk.cmdline.options;

import mltk.cmdline.Argument;

public class LearnerWithTaskOptions extends LearnerOptions {

	@Argument(name = "-g", description = "task between classification (c) and regression (r) (default: r)")
	public String task = "r";
	
}


================================================
FILE: src/main/java/mltk/cmdline/options/package-info.java
================================================
/**
 * Provides classes for command line options.
 *
 */
package mltk.cmdline.options;

================================================
FILE: src/main/java/mltk/cmdline/package-info.java
================================================
/**
 * Provides classes for command line parser.
 */
package mltk.cmdline;

================================================
FILE: src/main/java/mltk/core/Attribute.java
================================================
package mltk.core;

/**
 * Abstract class for attributes.
 * 
 * @author Yin Lou
 * 
 */
public abstract class Attribute implements Comparable<Attribute>, Copyable<Attribute> {

	public enum Type {
		/**
		 * Nominal type.
		 */
		NOMINAL,
		/**
		 * Numeric type.
		 */
		NUMERIC,
		/**
		 * Binned type.
		 */
		BINNED;
	}

	protected Type type;

	protected int index;

	protected String name;

	/**
	 * Returns the type of this attribute.
	 * 
	 * @return the type of this attribute.
	 */
	public final Type getType() {
		return type;
	}

	/**
	 * Returns the index of this attribute.
	 * 
	 * @return the index of this attribute.
	 */
	public final int getIndex() {
		return index;
	}

	/**
	 * Sets the index of this attribute.
	 * 
	 * @param index the new index.
	 */
	public final void setIndex(int index) {
		this.index = index;
	}

	/**
	 * Returns the name of this attribute.
	 * 
	 * @return the name of this attribute.
	 */
	public final String getName() {
		return name;
	}

	@Override
	public int compareTo(Attribute att) {
		return (this.index - att.index);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + index;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Attribute other = (Attribute) obj;
		if (index != other.index)
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (type != other.type)
			return false;
		return true;
	}

	@Override
	public String toString() {
		return name;
	}

}


================================================
FILE: src/main/java/mltk/core/BinnedAttribute.java
================================================
package mltk.core;

import java.util.Arrays;

import mltk.util.ArrayUtils;

/**
 * Class for discretized attributes.
 * 
 * @author Yin Lou
 * 
 */
public class BinnedAttribute extends Attribute {

	protected int numBins;
	protected Bins bins;

	/**
	 * Constructor.
	 * 
	 * @param name the name of this attribute.
	 * @param numBins number of bins for this attribute.
	 */
	public BinnedAttribute(String name, int numBins) {
		this(name, numBins, -1);
	}

	/**
	 * Constructor.
	 * 
	 * @param name the name of this attribute.
	 * @param numBins number of bins for this attribute.
	 * @param index the index of this attribute.
	 */
	public BinnedAttribute(String name, int numBins, int index) {
		this.name = name;
		this.numBins = numBins;
		this.bins = null;
		this.index = index;
		this.type = Type.BINNED;
	}

	/**
	 * Constructor.
	 * 
	 * @param name the name of this attribute.
	 * @param bins bins for this attribute.
	 */
	public BinnedAttribute(String name, Bins bins) {
		this(name, bins, -1);
	}

	/**
	 * Constructor.
	 * 
	 * @param name the name of this attribute.
	 * @param bins bins for this attribute.
	 * @param index the index of this attribute.
	 */
	public BinnedAttribute(String name, Bins bins, int index) {
		this(name, bins.size());
		this.bins = bins;
		this.index = index;
	}

	@Override
	public BinnedAttribute copy() {
		BinnedAttribute copy = (bins == null ? new BinnedAttribute(name, numBins) : new BinnedAttribute(name, bins));
		copy.index = index;
		return copy;
	}

	/**
	 * Returns the number of bins.
	 * 
	 * @return the number of bins.
	 */
	public int getNumBins() {
		return numBins;
	}

	/**
	 * Returns the bins.
	 * 
	 * @return the bins.
	 */
	public Bins getBins() {
		return bins;
	}

	public String toString() {
		if (bins == null) {
			return name + ": binned (" + numBins + ")";
		} else {
			return name + ": binned (" + bins.size() + ";" + Arrays.toString(bins.boundaries) + ";"
					+ Arrays.toString(bins.medians) + ")";
		}
	}

	/**
	 * Parses a binned attribute object from a string.
	 * 
	 * @param str the string.
	 * @return a parsed binned attribute.
	 */
	public static BinnedAttribute parse(String str) {
		String[] data = str.split(": ");
		int start = data[1].indexOf('(') + 1;
		int end = data[1].indexOf(')');
		String[] strs = data[1].substring(start, end).split(";");
		int numBins = Integer.parseInt(strs[0]);
		if (strs.length == 1) {
			return new BinnedAttribute(data[0], numBins);
		} else {
			double[] boundaries = ArrayUtils.parseDoubleArray(strs[1]);
			double[] medians = ArrayUtils.parseDoubleArray(strs[2]);
			Bins bins = new Bins(boundaries, medians);
			return new BinnedAttribute(data[0], bins);
		}
	}

}


================================================
FILE: src/main/java/mltk/core/Bins.java
================================================
package mltk.core;

import mltk.util.ArrayUtils;

/**
 * Class for bins. Each bin is defined as its upper bound and median.
 * 
 * @author Yin Lou
 * 
 */
public class Bins {

	/**
	 * The upper bounds for each bin
	 */
	protected double[] boundaries;

	/**
	 * The medians for each bin
	 */
	protected double[] medians;

	protected Bins() {

	}

	/**
	 * Constructor.
	 * 
	 * @param boundaries the uppber bounds for each bin.
	 * @param medians the medians for each bin.
	 */
	public Bins(double[] boundaries, double[] medians) {
		if (boundaries.length != medians.length) {
			throw new IllegalArgumentException("Boundary size doesn't match medians size");
		}
		this.boundaries = boundaries;
		this.medians = medians;
	}

	/**
	 * Returns the number of bins.
	 * 
	 * @return the number of bins.
	 */
	public int size() {
		return boundaries.length;
	}

	/**
	 * Returns the bin index given a real value using binary search.
	 * 
	 * @param value the real value to discretize.
	 * @return the discretized index.
	 */
	public int getIndex(double value) {
		if (value < boundaries[0]) {
			return 0;
		} else if (value >= boundaries[boundaries.length - 1]) {
			return boundaries.length - 1;
		} else {
			return ArrayUtils.findInsertionPoint(boundaries, value);
		}
	}

	/**
	 * Returns the median of a bin.
	 * 
	 * @param index the index of the bin.
	 * @return the median of the bin.
	 */
	public double getValue(int index) {
		return medians[index];
	}

	/**
	 * Returns the upper bounds for each bin.
	 * 
	 * @return the upper bounds for each bin.
	 */
	public double[] getBoundaries() {
		return boundaries;
	}

	/**
	 * Returns the medians for each bin.
	 * 
	 * @return the medians for each bin.
	 */
	public double[] getMedians() {
		return medians;
	}

}


================================================
FILE: src/main/java/mltk/core/Copyable.java
================================================
package mltk.core;

/**
 * Copyable interface.
 * 
 * @author Yin Lou
 * 
 * @param <T> the type of the object.
 */
public interface Copyable<T> {

	/**
	 * Returns a (deep) copy of the object.
	 * 
	 * @return a (deep) copy of the object.
	 */
	public T copy();

}


================================================
FILE: src/main/java/mltk/core/DenseVector.java
================================================
package mltk.core;

import java.util.Arrays;

/**
 * Class for dense vectors.
 * 
 * @author Yin Lou
 * 
 */
public class DenseVector implements Vector {

	protected double[] values;

	/**
	 * Constructs a dense vector from a double array.
	 * 
	 * @param values the double array.
	 */
	public DenseVector(double[] values) {
		this.values = values;
	}

	@Override
	public double getValue(int index) {
		return values[index];
	}

	@Override
	public double[] getValues() {
		return values;
	}

	@Override
	public double[] getValues(int... indices) {
		double[] values = new double[indices.length];
		for (int i = 0; i < values.length; i++) {
			values[i] = getValue(indices[i]);
		}
		return values;
	}

	@Override
	public void setValue(int index, double value) {
		values[index] = value;
	}

	@Override
	public void setValue(int[] indices, double[] v) {
		for (int i = 0; i < indices.length; i++) {
			values[indices[i]] = v[i];
		}
	}

	@Override
	public DenseVector copy() {
		double[] copyValues = Arrays.copyOf(values, values.length);
		return new DenseVector(copyValues);
	}

	@Override
	public boolean isSparse() {
		return false;
	}

}


================================================
FILE: src/main/java/mltk/core/Instance.java
================================================
package mltk.core;

import mltk.util.MathUtils;

/**
 * Class for instances.
 * 
 * @author Yin Lou
 * 
 */
public class Instance implements Copyable<Instance> {

	protected Vector vector;
	protected double[] target;
	protected double weight;

	/**
	 * Constructs a dense instance from values, target and weight.
	 * 
	 * @param values the values.
	 * @param target the target.
	 * @param weight the weight.
	 */
	public Instance(double[] values, double target, double weight) {
		this.vector = new DenseVector(values);
		this.target = new double[] { target };
		this.weight = weight;
	}

	/**
	 * Constructs a sparse instance from indices, values, target and weight.
	 * 
	 * @param indices the indices.
	 * @param values the values.
	 * @param target the target.
	 * @param weight the weight.
	 */
	public Instance(int[] indices, double[] values, double target, double weight) {
		this.vector = new SparseVector(indices, values);
		this.target = new double[] { target };
		this.weight = weight;
	}

	/**
	 * Constructs a dense instance from vector, target and weight.
	 * 
	 * @param vector the vector.
	 * @param target the target.
	 * @param weight the weight.
	 */
	public Instance(Vector vector, double target, double weight) {
		this.vector = vector;
		this.target = new double[] { target };
		this.weight = weight;
	}

	/**
	 * Constructor with default weight 1.0.
	 * 
	 * @param values the values.
	 * @param target the target.
	 */
	public Instance(double[] values, double target) {
		this(values, target, 1.0);
	}

	/**
	 * Constructor with default weight 1.0.
	 * 
	 * @param indices the indices.
	 * @param values the values.
	 * @param target the target.
	 */
	public Instance(int[] indices, double[] values, double target) {
		this(indices, values, target, 1.0);
	}

	/**
	 * Construct with default weight 1.0.
	 * 
	 * @param vector the vector.
	 * @param target the target.
	 */
	public Instance(Vector vector, double target) {
		this(vector, target, 1.0);
	}

	/**
	 * Constructor with default weight 1.0 and no target.
	 * 
	 * @param values the values.
	 */
	public Instance(double[] values) {
		this(values, Double.NaN);
	}

	/**
	 * Constructor with default weight 1.0 and no target.
	 * 
	 * @param indices the indices.
	 * @param values the values.
	 */
	public Instance(int[] indices, double[] values) {
		this(indices, values, Double.NaN);
	}

	/**
	 * Constructor with default weight 1.0 and no target.
	 * 
	 * @param vector the vector.
	 * @param values the values.
	 */
	public Instance(Vector vector, double[] values) {
		this(vector, Double.NaN);
	}

	/**
	 * Copy constructor.
	 * 
	 * @param instance the other instance to copy.
	 */
	public Instance(Instance instance) {
		this.vector = instance.vector;
		this.weight = instance.weight;
		this.target = instance.target;
	}

	/**
	 * Returns {@code true} if the instance is sparse.
	 * 
	 * @return {@code true} if the instance is sparse.
	 */
	public boolean isSparse() {
		return vector.isSparse();
	}

	/**
	 * Returns the value at specified attribute.
	 * 
	 * @param attIndex the attribute index.
	 * @return the value at specified attribute.
	 */
	public final double getValue(int attIndex) {
		return vector.getValue(attIndex);
	}

	/**
	 * Returns the values.
	 * 
	 * @return the values.
	 */
	public final double[] getValues() {
		return vector.getValues();
	}

	/**
	 * Returns an array representation of values at specified attributes.
	 * 
	 * @param attributes the attributes.
	 * @return an array representation of values at specified attributes.
	 */
	public final double[] getValues(int... attributes) {
		return vector.getValues(attributes);
	}

	/**
	 * Sets the value at specified attribute.
	 * 
	 * @param attIndex the attribute index.
	 * @param value the new value to set.
	 */
	public final void setValue(int attIndex, double value) {
		vector.setValue(attIndex, value);
	}

	/**
	 * Sets the value at specified attribute.
	 * 
	 * @param attribute the attribute.
	 * @param value the new value to set.
	 */
	public final void setValue(Attribute attribute, double value) {
		setValue(attribute.getIndex(), value);
	}

	/**
	 * Sets the values at specified attributes.
	 * 
	 * @param attributes the attribute index array.
	 * @param v the value array.
	 */
	public final void setValue(int[] attributes, double[] v) {
		for (int i = 0; i < attributes.length; i++) {
			setValue(attributes[i], v[i]);
		}
	}

	@Override
	public Instance copy() {
		Vector copyVector = vector.copy();
		return new Instance(copyVector, target[0], weight);
	}

	/**
	 * Returns a shallow copy.
	 * 
	 * @return a shallow copy.
	 */
	public Instance clone() {
		return new Instance(this);
	}

	/**
	 * Returns {@code true} if a specific attribute value is missing.
	 * 
	 * @param attIndex the attribute index.
	 * @return {@code true} if a specific attribute value is missing.
	 */
	public boolean isMissing(int attIndex) {
		return Double.isNaN(getValue(attIndex));
	}

	/**
	 * Returns the value at specified attribute.
	 * 
	 * @param att the attribute object.
	 * @return the value at specified attribute.
	 */
	public double getValue(Attribute att) {
		return getValue(att.getIndex());
	}

	/**
	 * Returns the vector.
	 * 
	 * @return the vector.
	 */
	public Vector getVector() {
		return vector;
	}

	/**
	 * Returns the weight of this instance.
	 * 
	 * @return the weight of this instance.
	 */
	public double getWeight() {
		return weight;
	}

	/**
	 * Sets the weight of this instance.
	 * 
	 * @param weight the new weight of this instance.
	 */
	public void setWeight(double weight) {
		this.weight = weight;
	}

	/**
	 * Returns the target value.
	 * 
	 * @return the target value.
	 */
	public double getTarget() {
		return target[0];
	}

	/**
	 * Sets the target value.
	 * 
	 * @param target the new target value.
	 */
	public void setTarget(double target) {
		this.target[0] = target;
	}

	/**
	 * Returns the string representation of this instance.
	 */
	public String toString() {
		StringBuilder sb = new StringBuilder();
		if (isSparse()) {
			sb.append(getTarget());
			SparseVector sv = (SparseVector) vector;
			int[] indices = sv.getIndices();
			double[] values = sv.getValues();
			for (int i = 0; i < indices.length; i++) {
				sb.append(" ").append(indices[i]).append(":");
				print(sb, values[i]);
			}
		} else {
			double[] values = getValues();
			print(sb, values[0]);
			for (int i = 1; i < values.length; i++) {
				sb.append("\t");
				print(sb, values[i]);
			}
			if (!Double.isNaN(getTarget())) {
				sb.append("\t");
				print(sb, getTarget());
			}
		}
		return sb.toString();
	}
	
	protected void print(StringBuilder sb, double v) {
		if (MathUtils.isInteger(v)) {
			sb.append((int) v);
		} else {
			sb.append(v);
		}
	}

}


================================================
FILE: src/main/java/mltk/core/Instances.java
================================================
package mltk.core;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

import mltk.util.Random;

/**
 * Class for handling an ordered set of instances.
 * 
 * @author Yin Lou
 * 
 */
public class Instances implements Iterable<Instance>, Copyable<Instances> {

	protected List<Attribute> attributes;
	protected List<Instance> instances;
	protected Attribute targetAtt;

	/**
	 * Constructs a dataset from attributes.
	 * 
	 * @param attributes the attributes.
	 */
	public Instances(List<Attribute> attributes) {
		this(attributes, null);
	}

	/**
	 * Constructs a dataset from attributes, with specified capacity.
	 * 
	 * @param attributes the attributes.
	 * @param capacity the capacity.
	 */
	public Instances(List<Attribute> attributes, int capacity) {
		this(attributes, null, capacity);
	}

	/**
	 * Constructs a dataset from attributes and target attribute.
	 * 
	 * @param attributes the attributes.
	 * @param targetAtt the target attribute.
	 */
	public Instances(List<Attribute> attributes, Attribute targetAtt) {
		this(attributes, targetAtt, 1000);
	}

	/**
	 * Constructs a dataset from attributes and target attribute, with specified capacity.
	 * 
	 * @param attributes the attributes.
	 * @param targetAtt the target attribute.
	 * @param capacity the capacity.
	 */
	public Instances(List<Attribute> attributes, Attribute targetAtt, int capacity) {
		this.attributes = attributes;
		this.targetAtt = targetAtt;
		this.instances = new ArrayList<>(capacity);
	}

	/**
	 * Copy constructor.
	 * 
	 * @param instances the instances to copy.
	 */
	public Instances(Instances instances) {
		this.attributes = instances.attributes;
		this.targetAtt = instances.targetAtt;
		this.instances = new ArrayList<>(instances.instances);
	}

	/**
	 * Adds an instance to the end of the dataset.
	 * 
	 * @param instance the instance to add.
	 */
	public void add(Instance instance) {
		instances.add(instance);
	}

	/**
	 * Returns the instance at given index.
	 * 
	 * @param index the index.
	 * @return the instance at given index.
	 */
	public Instance get(int index) {
		return instances.get(index);
	}

	/**
	 * Returns the target attribute.
	 * 
	 * @return the target attribute.
	 */
	public final Attribute getTargetAttribute() {
		return targetAtt;
	}

	/**
	 * Sets the target attribute.
	 * 
	 * @param targetAtt the target attribute.
	 */
	public final void setTargetAttribute(Attribute targetAtt) {
		this.targetAtt = targetAtt;
	}

	@Override
	public Iterator<Instance> iterator() {
		return instances.iterator();
	}

	/**
	 * Returns the size of this dataset, i.e., the number of instances.
	 * 
	 * @return the size of this dataset.
	 */
	public final int size() {
		return instances.size();
	}

	/**
	 * Returns the dimension of this dataset, i.e., the number of attributes. Note that class attribute does not count.
	 * 
	 * @return the dimension of this dataset.
	 */
	public final int dimension() {
		return attributes.size();
	}

	/**
	 * Returns the list of attributes.
	 * 
	 * @return the list of attributes.
	 */
	public List<Attribute> getAttributes() {
		return attributes;
	}

	/**
	 * Returns the list of attributes at given locations.
	 * 
	 * @param indices the indices.
	 * @return the list of attributes at given locations.
	 */
	public List<Attribute> getAttributes(int... indices) {
		List<Attribute> attributes = new ArrayList<>(indices.length);
		for (int index : indices) {
			attributes.add(this.attributes.get(index));
		}
		return attributes;
	}

	/**
	 * Sets the attributes.
	 * 
	 * @param attributes the attributes to set.
	 */
	public void setAttributes(List<Attribute> attributes) {
		this.attributes = attributes;
	}

	/**
	 * Resets this dataset.
	 */
	public void clear() {
		instances.clear();
	}

	/**
	 * Randomly permutes this dataset.
	 */
	public void shuffle() {
		Collections.shuffle(instances, Random.getInstance().getRandom());
	}

	/**
	 * Randomly permutes this dataset.
	 * 
	 * @param rand the source of randomness to use to shuffle the dataset.
	 */
	public void shuffle(java.util.Random rand) {
		Collections.shuffle(instances, rand);
	}

	@Override
	public Instances copy() {
		List<Attribute> attributes = new ArrayList<>(this.attributes);
		Instances copy = new Instances(attributes, targetAtt, instances.size());
		for (Instance instance : instances) {
			copy.add(instance.copy());
		}
		return copy;
	}

}


================================================
FILE: src/main/java/mltk/core/NominalAttribute.java
================================================
package mltk.core;

/**
 * Class for nominal attributes.
 * 
 * @author Yin Lou
 * 
 */
public class NominalAttribute extends Attribute {

	protected String[] states;

	/**
	 * Constructor.
	 * 
	 * @param name the name of this attribute.
	 * @param states the states for this attribute.
	 */
	public NominalAttribute(String name, String[] states) {
		this(name, states, -1);
	}

	/**
	 * Constructor.
	 * 
	 * @param name the name of this attribute.
	 * @param states the states for this attribute.
	 * @param index the index of this attribute.
	 */
	public NominalAttribute(String name, String[] states, int index) {
		this.name = name;
		this.states = states;
		this.index = index;
		this.type = Type.NOMINAL;
	}

	public NominalAttribute copy() {
		NominalAttribute copy = new NominalAttribute(name, states);
		copy.index = this.index;
		return copy;
	}

	/**
	 * Returns the cardinality of this attribute.
	 * 
	 * @return the cardinality of this attribute.
	 */
	public int getCardinality() {
		return states.length;
	}

	/**
	 * Returns the state given an index.
	 * 
	 * @param index the index.
	 * @return the state given an index.
	 */
	public String getState(int index) {
		return states[index];
	}

	/**
	 * Returns the states.
	 * 
	 * @return the states.
	 */
	public String[] getStates() {
		return states;
	}

	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append(name).append(": {").append(states[0]);
		for (int i = 1; i < states.length; i++) {
			sb.append(", ").append(states[i]);
		}
		sb.append("}");
		return sb.toString();
	}

	/**
	 * Parses a nominal attribute ojbect from a string.
	 * 
	 * @param str the string.
	 * @return a parsed nominal attribute.
	 */
	public static NominalAttribute parse(String str) {
		String[] data = str.split(": ");
		int start = data[1].indexOf('{') + 1;
		int end = data[1].indexOf('}');
		String[] states = data[1].substring(start, end).split(",");
		for (int j = 0; j < states.length; j++) {
			states[j] = states[j].trim();
		}
		return new NominalAttribute(data[0], states);
	}

}


================================================
FILE: src/main/java/mltk/core/NumericalAttribute.java
================================================
package mltk.core;

/**
 * Class for numerical attributes.
 * 
 * @author Yin Lou
 * 
 */
public class NumericalAttribute extends Attribute {

	/**
	 * Constructor.
	 * 
	 * @param name the name of this attribute.
	 */
	public NumericalAttribute(String name) {
		this(name, -1);
	}

	/**
	 * Constructor.
	 * 
	 * @param name the name of this attribute.
	 * @param index the index of this attribute.
	 */
	public NumericalAttribute(String name, int index) {
		this.name = name;
		this.index = index;
		this.type = Type.NUMERIC;
	}

	public NumericalAttribute copy() {
		NumericalAttribute copy = new NumericalAttribute(this.name);
		copy.index = this.index;
		return copy;
	}

	public String toString() {
		return name + ": cont";
	}

	/**
	 * Parses a numerical attribute object from a string.
	 * 
	 * @param str the string.
	 * @return a parsed numerical attribute.
	 */
	public static NumericalAttribute parse(String str) {
		String[] data = str.split(": ");
		return new NumericalAttribute(data[0]);
	}

}


================================================
FILE: src/main/java/mltk/core/Sampling.java
================================================
package mltk.core;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import mltk.util.Permutation;
import mltk.util.Random;
import mltk.util.tuple.IntPair;

/**
 * Class for creating samples.
 * 
 * @author Yin Lou
 * 
 */
public class Sampling {

	/**
	 * Returns a bootstrap sample.
	 * 
	 * @param instances the data set.
	 * @return a bootstrap sample.
	 */
	public static Instances createBootstrapSample(Instances instances) {
		Random rand = Random.getInstance();
		Map<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < instances.size(); i++) {
			int idx = rand.nextInt(instances.size());
			map.put(idx, map.getOrDefault(idx, 0) + 1);
		}
		Instances bag = new Instances(instances.getAttributes(), instances.getTargetAttribute(), map.size());
		for (Integer idx : map.keySet()) {
			int weight = map.get(idx);
			Instance instance = instances.get(idx).clone();
			instance.setWeight(weight);
			bag.add(instance);
		}
		return bag;
	}

	/**
	 * Returns a bootstrap sample with out-of-bag samples.
	 * 
	 * @param instances the data set.
	 * @param bagIndices the index of sampled instances with weights.
	 * @param oobIndices the out-of-bag indexes.
	 */
	public static void createBootstrapSample(Instances instances, Map<Integer, Integer> bagIndices,
			List<Integer> oobIndices) {
		Random rand = Random.getInstance();
		for (;;) {
			bagIndices.clear();
			oobIndices.clear();
			for (int i = 0; i < instances.size(); i++) {
				int idx = rand.nextInt(instances.size());
				bagIndices.put(idx, bagIndices.getOrDefault(idx, 0) + 1);
			}
			for (int i = 0; i < instances.size(); i++) {
				if (!bagIndices.containsKey(i)) {
					oobIndices.add(i);
				}
			}
			if (oobIndices.size() > 0) {
				break;
			}
		}
	}
	
	/**
	 * Returns a bootstrap sample of indices and weights.
	 * 
	 * @param n the size of the dataset to sample.
	 * @return a bootstrap sample of indices and weights.
	 */
	public static IntPair[] createBootstrapSampleIndices(int n) {
		Random rand = Random.getInstance();
		Map<Integer, Integer> map = new HashMap<>();
		for (int i = 0; i < n; i++) {
			int idx = rand.nextInt(n);
			map.put(idx, map.getOrDefault(idx, 0) + 1);
		}
		IntPair[] indices = new IntPair[map.size()];
		int k = 0;
		for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
			indices[k++] = new IntPair(entry.getKey(), entry.getValue());
		}
		return indices;
	}

	/**
	 * Returns a subsample.
	 * 
	 * @param instances the dataset.
	 * @param n the sample size.
	 * @return a subsample.
	 */
	public static Instances createSubsample(Instances instances, int n) {
		Permutation perm = new Permutation(instances.size());
		perm.permute();
		int[] a = perm.getPermutation();
		Instances sample = new Instances(instances.getAttributes(), instances.getTargetAttribute(), n);
		for (int i = 0; i < n; i++) {
			sample.add(instances.get(a[i]));
		}
		return sample;
	}

	/**
	 * Returns a set of bags.
	 * 
	 * @param instances the dataset.
	 * @param b the number of bagging iterations.
	 * @return a set of bags.
	 */
	public static Instances[] createBags(Instances instances, int b) {
		Instances[] bags = null;
		if (b <= 0) {
			// No bagging
			bags = new Instances[] { instances };
		} else {
			bags = new Instances[b];
			for (int i = 0; i < b; i++) {
				bags[i] = Sampling.createBootstrapSample(instances);
			}
		}
		return bags;
	}

}


================================================
FILE: src/main/java/mltk/core/SparseVector.java
================================================
package mltk.core;

import java.util.Arrays;

/**
 * Class for sparse vectors.
 * 
 * @author Yin Lou
 * 
 */
public class SparseVector implements Vector {

	protected int[] indices;
	protected double[] values;

	/**
	 * Constructs a sparse vector from sparse-format arrays.
	 * 
	 * @param indices the indices array.
	 * @param values the values array.
	 */
	public SparseVector(int[] indices, double[] values) {
		this.indices = indices;
		this.values = values;
	}

	@Override
	public SparseVector copy() {
		int[] copyIndices = Arrays.copyOf(indices, indices.length);
		double[] copyValues = Arrays.copyOf(values, values.length);
		return new SparseVector(copyIndices, copyValues);
	}

	@Override
	public double getValue(int index) {
		int idx = Arrays.binarySearch(indices, index);
		if (idx >= 0) {
			return values[idx];
		} else {
			return 0;
		}
	}

	@Override
	public double[] getValues() {
		return values;
	}

	/**
	 * Returns the internal representation of indices.
	 * 
	 * @return the internal representation of indices.
	 */
	public int[] getIndices() {
		return indices;
	}

	@Override
	public double[] getValues(int... indices) {
		double[] values = new double[indices.length];
		for (int i = 0; i < values.length; i++) {
			values[i] = getValue(indices[i]);
		}
		return values;
	}

	@Override
	public void setValue(int index, double value) {
		int idx = Arrays.binarySearch(indices, index);
		if (idx >= 0) {
			values[idx] = value;
		} else {
			throw new UnsupportedOperationException();
		}
	}

	@Override
	public void setValue(int[] indices, double[] v) {
		for (int i = 0; i < indices.length; i++) {
			setValue(indices[i], v[i]);
		}
	}

	@Override
	public boolean isSparse() {
		return true;
	}

}


================================================
FILE: src/main/java/mltk/core/Vector.java
================================================
package mltk.core;

/**
 * Interface for vectors.
 * 
 * @author Yin Lou
 * 
 */
public interface Vector extends Copyable<Vector> {

	/**
	 * Returns the value at specified index.
	 * 
	 * @param index the index.
	 * @return the value at specified index.
	 */
	public double getValue(int index);

	/**
	 * Returns the internal representation of values.
	 * 
	 * @return the internal representation of values.
	 */
	public double[] getValues();

	/**
	 * Returns an array representation of values at specified indices.
	 * 
	 * @param indices the indices.
	 * @return an array representation of values at specified indices.
	 */
	public double[] getValues(int... indices);

	/**
	 * Sets the value at specified index.
	 * 
	 * @param index the index.
	 * @param value the new value to set.
	 */
	public void setValue(int index, double value);

	/**
	 * Sets the values at specified indices.
	 * 
	 * @param indices the index array.
	 * @param v the value array.
	 */
	public void setValue(int[] indices, double[] v);

	/**
	 * Returns {@code true} if the vector is sparse.
	 * 
	 * @return {@code true} if the vector is sparse.
	 */
	public boolean isSparse();

	/**
	 * Returns a (deep) copy of the vector.
	 * 
	 * @return a (deep) copy of the vector.
	 */
	public Vector copy();

}


================================================
FILE: src/main/java/mltk/core/Writable.java
================================================
package mltk.core;

import java.io.BufferedReader;
import java.io.PrintWriter;

/**
 * Writable interface.
 * 
 * @author Yin Lou
 * 
 */
public interface Writable {

	/**
	 * Reads in this object.
	 * 
	 * @param in the reader.
	 * @throws Exception
	 */
	void read(BufferedReader in) throws Exception;

	/**
	 * Writes this object.
	 * 
	 * @param out the writer.
	 * @throws Exception
	 */
	void write(PrintWriter out) throws Exception;

}


================================================
FILE: src/main/java/mltk/core/io/AttributesReader.java
================================================
package mltk.core.io;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import mltk.core.Attribute;
import mltk.core.BinnedAttribute;
import mltk.core.NominalAttribute;
import mltk.core.NumericalAttribute;
import mltk.util.tuple.Pair;

/**
 * Class for reading attributes. It only reads in a list of attributes from the attribute file.
 * 
 * @author Yin Lou
 * 
 */
public class AttributesReader {

	/**
	 * Reads attributes and class attribute from attribute file.
	 * 
	 * @param attFile the attribute file.
	 * @return a pair of attributes and target attribute (null if no target attribute).
	 * @throws IOException
	 */
	public static Pair<List<Attribute>, Attribute> read(String attFile) throws IOException {
		BufferedReader br = new BufferedReader(new FileReader(attFile), 65535);
		Pair<List<Attribute>, Attribute> pair = read(br);
		br.close();

		return pair;
	}
	
	/**
	 * Reads attributes and class attribute from attribute file.
	 * 
	 * @param br the reader.
	 * @return a pair of attributes and target attribute (null if no target attribute).
	 * @throws IOException
	 */
	public static Pair<List<Attribute>, Attribute> read(BufferedReader br) throws IOException {
		List<Attribute> attributes = new ArrayList<Attribute>();
		Attribute targetAtt = null;
		Set<String> usedNames = new HashSet<>();
		for (int i = 0;; i++) {
			String line = br.readLine();
			if (line == null) {
				break;
			}
			Attribute att = null;
			if (line.indexOf("binned") != -1) {
				att = BinnedAttribute.parse(line);
			} else if (line.indexOf("{") != -1) {
				att = NominalAttribute.parse(line);
			} else {
				att = NumericalAttribute.parse(line);
			}
			att.setIndex(i);
			if (line.indexOf(" (target)") != -1) {
				targetAtt = att;
				i--;
			} else {
				if (usedNames.contains(att.getName())) {
					throw new RuntimeException("Duplicate attribute name: " + att.getName());
				}
				usedNames.add(att.getName());
				attributes.add(att);
			}
			if (line.indexOf(" (x)") != -1) {
				att.setIndex(-1);
			}
		}

		return new Pair<List<Attribute>, Attribute>(attributes, targetAtt);
	}

}


================================================
FILE: src/main/java/mltk/core/io/InstancesReader.java
================================================
package mltk.core.io;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.TreeSet;

import mltk.core.Attribute;
import mltk.core.Instance;
import mltk.core.Instances;
import mltk.core.NominalAttribute;
import mltk.core.NumericalAttribute;
import mltk.util.MathUtils;
import mltk.util.tuple.Pair;

/**
 * Class for reading instances.
 * 
 * @author Yin Lou
 * 
 */
public class InstancesReader {

	/**
	 * Reads a set of instances from attribute file and data file. Attribute file can be null. Default delimiter is
	 * whitespace.
	 * 
	 * @param attFile the attribute file.
	 * @param dataFile the data file.
	 * @return a set of instances.
	 * @throws IOException
	 */
	public static Instances read(String attFile, String dataFile) throws IOException {
		return read(attFile, dataFile, "\\s+");
	}

	/**
	 * Reads a set of instances from attribute file and data file. Attribute file can be null.
	 * 
	 * @param attFile the attribute file.
	 * @param dataFile the data file.
	 * @param delimiter the delimiter.
	 * @return a set of instances.
	 * @throws IOException
	 */
	public static Instances read(String attFile, String dataFile, String delimiter) throws IOException {
		if (attFile != null) {
			Pair<List<Attribute>, Attribute> pair = AttributesReader.read(attFile);
			int classIndex = -1;
			if (pair.v2 != null) {
				classIndex = pair.v2.getIndex();
				pair.v2.setIndex(-1);
			}
			List<Attribute> attributes = pair.v1;
			Instances instances = new Instances(attributes, pair.v2);
			int totalLength = instances.dimension();
			if (classIndex != -1) {
				totalLength++;
			}
			BufferedReader br = new BufferedReader(new FileReader(dataFile), 65535);
			for (;;) {
				String line = br.readLine();
				if (line == null) {
					break;
				}
				String[] data = line.split(delimiter);
				Instance instance = null;
				if (data.length >= 2 && data[1].indexOf(':') >= 0) {
					// Sparse instance
					instance = parseSparseInstance(data);
				} else if (data.length == totalLength) {
					// Dense instance
					instance = parseDenseInstance(data, classIndex);
				} else {
					System.err.println("Processed as dense vector but the number of attributes provided in the attribute file does not match with the number of columns in this row");
				}
				if (instance != null) {
					instances.add(instance);
				}
			}
			br.close();
			
			// Process skipped features
			for (int i = attributes.size() - 1; i >= 0; i--) {
				if (attributes.get(i).getIndex() < 0) {
					attributes.remove(i);
				}
			}
			
			return instances;
		} else {
			List<Attribute> attributes = new ArrayList<>();
			Instances instances = new Instances(attributes);
			int totalLength = -1;

			TreeSet<Integer> attrSet = new TreeSet<>();
			BufferedReader br = new BufferedReader(new FileReader(dataFile), 65535);
			for (;;) {
				String line = br.readLine();
				if (line == null) {
					break;
				}
				String[] data = line.split(delimiter);
				Instance instance = null;
				if (data.length >= 2 && data[1].indexOf(':') >= 0) {
					// Sparse instance
					instance = parseSparseInstance(data, attrSet);
				} else {
					// Dense instance
					if (totalLength == -1) {
						totalLength = data.length;
					} else if (data.length == totalLength) {
						instance = parseDenseInstance(data, -1);
					}

				}
				if (instance != null) {
					instances.add(instance);
				}
			}
			br.close();

			if (totalLength == -1) {
				for (Integer attIndex : attrSet) {
					Attribute att = new NumericalAttribute("f" + attIndex);
					att.setIndex(attIndex);
					attributes.add(att);
				}
			} else {
				for (int j = 0; j < totalLength; j++) {
					Attribute att = new NumericalAttribute("f" + j);
					att.setIndex(j);
					attributes.add(att);
				}
			}

			assignTargetAttribute(instances);
			return instances;
		}
	}

	/**
	 * Reads a set of dense instances from data file. Default delimiter is whitespace.
	 * 
	 * @param file the data file.
	 * @param targetIndex the index of the target attribute, -1 if no target attribute.
	 * @return a set of dense instances.
	 * @throws IOException
	 */
	public static Instances read(String file, int targetIndex) throws IOException {
		return read(file, targetIndex, "\\s+");
	}

	/**
	 * Reads a set of dense instances from data file.
	 * 
	 * @param file the data file.
	 * @param targetIndex the index of the target attribute, -1 if no target attribute.
	 * @param delimiter the delimiter.
	 * @return a set of dense instances.
	 * @throws IOException
	 */
	public static Instances read(String file, int targetIndex, String delimiter) throws IOException {
		BufferedReader br = new BufferedReader(new FileReader(file), 65535);
		List<Attribute> attributes = new ArrayList<>();
		Instances instances = new Instances(attributes);
		for (;;) {
			String line = br.readLine();
			if (line == null) {
				break;
			}
			String[] data = line.split(delimiter);
			Instance instance = parseDenseInstance(data, targetIndex);
			instances.add(instance);
		}
		br.close();

		int numAttributes = instances.get(0).getValues().length;
		for (int i = 0; i < numAttributes; i++) {
			Attribute att = new NumericalAttribute("f" + i);
			att.setIndex(i);
			attributes.add(att);
		}

		if (targetIndex >= 0) {
			assignTargetAttribute(instances);
		}

		return instances;
	}

	/**
	 * Parses a dense instance from strings.
	 * 
	 * @param data the string array.
	 * @param classIndex the class index.
	 * @return a dense instance from strings.
	 */
	static Instance parseDenseInstance(String[] data, int classIndex) {
		double classValue = Double.NaN;
		if (classIndex < 0) {
			double[] vector = new double[data.length];
			for (int i = 0; i < data.length; i++) {
				vector[i] = parseDouble(data[i]);
			}
			return new Instance(vector, classValue);
		} else {
			double[] vector = new double[data.length - 1];
			for (int i = 0; i < data.length; i++) {
				double value = parseDouble(data[i]);
				if (i < classIndex) {
					vector[i] = value;
				} else if (i > classIndex) {
					vector[i - 1] = value;
				} else {
					classValue = value;
				}
			}
			return new Instance(vector, classValue);
		}
	}

	/**
	 * Parses a sparse instance from strings.
	 * 
	 * @param data the string array.
	 * @param attrSet the attributes set.
	 * @return a sparse instance from strings.
	 */
	private static Instance parseSparseInstance(String[] data, TreeSet<Integer> attrSet) {
		double targetValue = Double.parseDouble(data[0]);
		int[] indices = new int[data.length - 1];
		double[] values = new double[data.length - 1];
		for (int i = 0; i < indices.length; i++) {
			String[] pair = data[i + 1].split(":");
			indices[i] = Integer.parseInt(pair[0]);
			values[i] = Double.parseDouble(pair[1]);
			attrSet.add(indices[i]);
		}
		return new Instance(indices, values, targetValue);
	}

	/**
	 * Parses a sparse instance from strings.
	 * 
	 * @param data the string array.
	 * @return a sparse instance from strings.
	 */
	private static Instance parseSparseInstance(String[] data) {
		double classValue = Double.parseDouble(data[0]);
		int[] indices = new int[data.length - 1];
		double[] values = new double[data.length - 1];
		for (int i = 0; i < indices.length; i++) {
			String[] pair = data[i + 1].split(":");
			indices[i] = Integer.parseInt(pair[0]);
			values[i] = Double.parseDouble(pair[1]);
		}
		return new Instance(indices, values, classValue);
	}

	/**
	 * Assigns target attribute for a dataset.
	 * 
	 * @param instances the data set.
	 */
	private static void assignTargetAttribute(Instances instances) {
		boolean isInteger = true;
		for (Instance instance : instances) {
			if (!MathUtils.isInteger(instance.getTarget())) {
				isInteger = false;
				break;
			}
		}
		if (isInteger) {
			TreeSet<Integer> set = new TreeSet<>();
			for (Instance instance : instances) {
				double target = instance.getTarget();
				set.add((int) target);
			}
			String[] states = new String[set.size()];
			int i = 0;
			for (Integer v : set) {
				states[i++] = v.toString();
			}
			instances.setTargetAttribute(new NominalAttribute("target", states));
		} else {
			instances.setTargetAttribute(new NumericalAttribute("target"));
		}
	}
	
	/**
	 * Parses double value from a string. Missing value is supported.
	 * 
	 * @param s the string to parse.
	 * @return double value.
	 */
	private static double parseDouble(String s) {
		if (s.equals("?")) {
			return Double.NaN;
		} else {
			return Double.parseDouble(s);
		}
	}

}


================================================
FILE: src/main/java/mltk/core/io/InstancesWriter.java
================================================
package mltk.core.io;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import mltk.core.Attribute;
import mltk.core.Instance;
import mltk.core.Instances;

/**
 * Class for writing instances.
 * 
 * @author Yin Lou
 * 
 */
public class InstancesWriter {

	/**
	 * Writes a set of dense instances to attribute file and data file.
	 * 
	 * @param instances the dense instances to write.
	 * @param attFile the attribute file path.
	 * @param dataFile the data file path.
	 * @throws IOException
	 */
	public static void write(Instances instances, String attFile, String dataFile) throws IOException {
		List<Attribute> attributes = instances.getAttributes();
		PrintWriter out = new PrintWriter(attFile);
		for (Attribute attribute : attributes) {
			out.println(attribute);
		}
		out.println(instances.getTargetAttribute() + " (target)");
		out.flush();
		out.close();

		write(instances, dataFile);
	}

	/**
	 * Writes a set of dense/sparse instances to data file.
	 * 
	 * @param instances the dense instances to write.
	 * @param file the data file path.
	 * @throws IOException
	 */
	public static void write(Instances instances, String file) throws IOException {
		PrintWriter out = new PrintWriter(file);
		for (Instance instance : instances) {
			out.println(instance);
		}
		out.flush();
		out.close();
	}

}


================================================
FILE: src/main/java/mltk/core/io/package-info.java
================================================
/**
 * Contains classes for reading and writing datasets.
 */
package mltk.core.io;

================================================
FILE: src/main/java/mltk/core/package-info.java
================================================
/**
 * Provides classes and interfaces for handling datasets and attributes.
 */
package mltk.core;

================================================
FILE: src/main/java/mltk/core/processor/Discretizer.java
================================================
package mltk.core.processor;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import mltk.cmdline.Argument;
import mltk.cmdline.CmdLineParser;
import mltk.core.Attribute;
import mltk.core.BinnedAttribute;
import mltk.core.Bins;
import mltk.core.Instance;
import mltk.core.Instances;
import mltk.core.Attribute.Type;
import mltk.core.io.AttributesReader;
import mltk.core.io.InstancesReader;
import mltk.core.io.InstancesWriter;
import mltk.util.Element;
import mltk.util.tuple.DoublePair;

/**
 * Class for discretizers.
 * 
 * @author Yin Lou
 * 
 */
public class Discretizer {
	
	static class Options {

		@Argument(name = "-r", description = "attribute file path")
		String attPath = null;
		
		@Argument(name = "-t", description = "training file path")
		String trainPath = null;

		@Argument(name = "-i", description = "input dataset path", required = true)
		String inputPath = null;

		@Argument(name = "-d", description = "discretized attribute file path")
		String disAttPath = null;

		@Argument(name = "-m", description = "output attribute file path")
		String outputAttPath = null;

		@Argument(name = "-o", description = "output dataset path", required = true)
		String outputPath = null;

		@Argument(name = "-n", description = "maximum num of bins (default: 256)")
		int maxNumBins = 256;

	}
	
	/**
	 * Discretizes datasets.
	 * 
	 * <pre>
	 * Usage: mltk.core.processor.Discretizer
	 * -i	input dataset path
	 * -o	output dataset path
	 * [-r]	attribute file path
	 * [-t]	training file path
	 * [-d]	discretized attribute file path
	 * [-m]	output attribute file path
	 * [-n]	maximum num of bins (default: 256)
	 * </pre>
	 * 
	 * @param args the command line arguments.
	 * @throws Exception
	 */
	public static void main(String[] args) throws Exception {
		Options app = new Options();
		CmdLineParser parser = new CmdLineParser(Discretizer.class, app);
		try {
			parser.parse(args);
			if (app.maxNumBins < 0) {
				throw new IllegalArgumentException();
			}
		} catch (IllegalArgumentException e) {
			parser.printUsage();
			System.exit(1);
		}
		List<Attribute> attributes = null;
		if (app.trainPath != null) {
			Instances trainSet = InstancesReader.read(app.attPath, app.trainPath);
			attributes = trainSet.getAttributes();
			for (int i = 0; i < attributes.size(); i++) {
				Attribute attribute = attributes.get(i);
				if (attribute.getType() == Type.NUMERIC) {
					// Only discretize numeric attributes
					Discretizer.discretize(trainSet, i, app.maxNumBins);
				}
			}
		} else if (app.disAttPath != null) {
			attributes = AttributesReader.read(app.disAttPath).v1;
		} else {
			parser.printUsage();
			System.exit(1);
		}

		Instances instances = InstancesReader.read(app.attPath, app.inputPath);
		List<Attribute> attrs = instances.getAttributes();
		for (int i = 0; i < attrs.size(); i++) {
			Attribute attr = attrs.get(i);
			if (attr.getType() == Type.NUMERIC) {
				BinnedAttribute binnedAttr = (BinnedAttribute) attributes.get(i);
				// Only discretize numeric attributes
				Discretizer.discretize(instances, i, binnedAttr.getBins());
			}
		}

		if (app.outputAttPath != null) {
			InstancesWriter.write(instances, app.outputAttPath, app.outputPath);
		} else {
			InstancesWriter.write(instances, app.outputPath);
		}
	}

	/**
	 * Compute bins for a list of values.
	 * 
	 * @param x the vector of input data.
	 * @param maxNumBins the number of bins.
	 * @return bins for a list of values.
	 */
	public static Bins computeBins(double[] x, int maxNumBins) {
		List<Element<Double>> list = new ArrayList<>();
		for (double v : x) {
			if (!Double.isNaN(v)) {
				list.add(new Element<Double>(1.0, v));
			}
		}
		return computeBins(list, maxNumBins);
	}

	/**
	 * Compute bins for a specified attribute.
	 * 
	 * @param instances the dataset to discretize.
	 * @param attIndex the attribute index.
	 * @param maxNumBins the number of bins.
	 * @return bins for a specified attribute.
	 */
	public static Bins computeBins(Instances instances, int attIndex, int maxNumBins) {
		Attribute attribute = instances.getAttributes().get(attIndex);
		List<Element<Double>> list = new ArrayList<>();
		for (Instance instance : instances) {
			if (!instance.isMissing(attribute.getIndex())) {
				list.add(new Element<Double>(instance.getWeight(), instance.getValue(attribute)));
			}
		}
		return computeBins(list, maxNumBins);
	}

	/**
	 * Compute bins for a list of values.
	 * 
	 * @param list the histogram.
	 * @param maxNumBins the number of bins.
	 * @return bins for a list of values.
	 */
	public static Bins computeBins(List<Element<Double>> list, int maxNumBins) {
		Collections.sort(list);
		List<DoublePair> stats = new ArrayList<>();
		getStats(list, stats);
		if (stats.size() <= maxNumBins) {
			double[] a = new double[stats.size()];
			for (int i = 0; i < a.length; i++) {
				a[i] = stats.get(i).v1;
			}
			return new Bins(a, a);
		} else {
			double totalWeight = 0;
			for (DoublePair stat : stats) {
				totalWeight += stat.v2;
			}
			double binSize = totalWeight / maxNumBins;
			List<Double> boundaryList = new ArrayList<>();
			List<Double> medianList = new ArrayList<>();
			int start = 0;
			double weight = 0;
			for (int i = 0; i < stats.size(); i++) {
				weight += stats.get(i).v2;
				totalWeight -= stats.get(i).v2;
				if (weight >= binSize) {
					if (i == start) {
						boundaryList.add(stats.get(start).v1);
						medianList.add(stats.get(start).v1);
						weight = 0;
						start = i + 1;
					} else {
						double d1 = weight - binSize;
						double d2 = stats.get(i).v2 - d1;
						if (d1 < d2) {
							boundaryList.add(stats.get(i).v1);
							medianList.add(getMedian(stats, start, weight / 2));
							start = i + 1;
							weight = 0;
						} else {
							weight -= stats.get(i).v2;
							boundaryList.add(stats.get(i - 1).v1);
							medianList.add(getMedian(stats, start, weight / 2));
							start = i;
							weight = stats.get(i).v2;
						}
					}
					binSize = (totalWeight + weight) / (maxNumBins - boundaryList.size());
				} else if (i == stats.size() - 1) {
					boundaryList.add(stats.get(i).v1);
					medianList.add(getMedian(stats, start, weight / 2));
				}
			}
			double[] boundaries = new double[boundaryList.size()];
			double[] medians = new double[medianList.size()];
			for (int i = 0; i < boundaries.length; i++) {
				boundaries[i] = boundaryList.get(i);
				medians[i] = medianList.get(i);
			}
			return new Bins(boundaries, medians);
		}
	}

	/**
	 * Discretizes an attribute using bins.
	 * 
	 * @param instances the dataset to discretize.
	 * @param attIndex the attribute index.
	 * @param bins the bins.
	 */
	public static void discretize(Instances instances, int attIndex, Bins bins) {
		Attribute attribute = instances.getAttributes().get(attIndex);
		BinnedAttribute binnedAttribute = new BinnedAttribute(attribute.getName(), bins);
		binnedAttribute.setIndex(attribute.getIndex());
		instances.getAttributes().set(attIndex, binnedAttribute);
		for (Instance instance : instances) {
			if (!instance.isMissing(attribute.getIndex())) {
				int v = bins.getIndex(instance.getValue(attribute.getIndex()));
				instance.setValue(attribute.getIndex(), v);
			}
		}
	}

	/**
	 * Discretized an attribute with specified number of bins.
	 * 
	 * @param instances the dataset to discretize.
	 * @param attIndex the attribute index.
	 * @param maxNumBins the number of bins.
	 */
	public static void discretize(Instances instances, int attIndex, int maxNumBins) {
		Bins bins = computeBins(instances, attIndex, maxNumBins);
		discretize(instances, attIndex, bins);
	}

	static double getMedian(List<DoublePair> stats, int start, double midPoint) {
		double weight = 0;
		for (int i = start; i < stats.size(); i++) {
			weight += stats.get(i).v2;
			if (weight >= midPoint) {
				return stats.get(i).v1;
			}
		}
		return stats.get((start + stats.size()) / 2).v1;
	}

	static void getStats(List<Element<Double>> list, List<DoublePair> stats) {
		if (list.size() == 0) {
			return;
		}
		double totalWeight = list.get(0).element;
		double lastValue = list.get(0).weight;
		for (int i = 1; i < list.size(); i++) {
			Element<Double> element = list.get(i);
			double value = element.weight;
			double weight = element.element;
			if (value != lastValue) {
				stats.add(new DoublePair(lastValue, totalWeight));
				lastValue = value;
				totalWeight = weight;
			} else {
				totalWeight += weight;
			}
		}
		stats.add(new DoublePair(lastValue, totalWeight));
	}

	/**
	 * Constructor.
	 */
	public Discretizer() {

	}

}


================================================
FILE: src/main/java/mltk/core/processor/InstancesSplitter.java
================================================
package mltk.core.processor;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import mltk.cmdline.Argument;
import mltk.cmdline.CmdLineParser;
import mltk.core.Attribute;
import mltk.core.Attribute.Type;
import mltk.core.BinnedAttribute;
import mltk.core.Instance;
import mltk.core.Instances;
import mltk.core.NominalAttribute;
import mltk.core.io.InstancesReader;
import mltk.core.io.InstancesWriter;
import mltk.util.MathUtils;
import mltk.util.Random;
import mltk.util.StatUtils;

/**
 * Class for cross validation.
 * 
 * @author Yin Lou
 * 
 */
public class InstancesSplitter {
	
	static class Options {

		@Argument(name = "-r", description = "attribute file path")
		String attPath = null;

		@Argument(name = "-i", description = "input dataset path", required = true)
		String inputPath = null;

		@Argument(name = "-o", description = "output directory path", required = true)
		String outputDirPath = null;

		@Argument(name = "-m", description = "splitting mode:parameter. Splitting mode can be split (s) and cross validation (c) (default: c:5)")
		String crossValidationMode = "c:5";
		
		@Argument(name = "-a", description = "attribute name to perform stratified sampling (default: null)")
		String attToStrafity = null;
		
		@Argument(name = "-s", description = "seed of the random number generator (default: 0)")
		long seed = 0L;
	}
	
	/**
	 * Splits a dataset.
	 * 
	 * <pre>
	 * Usage: mltk.core.processor.InstancesSplitter
	 * -i	input dataset path
	 * -o	output directory path
	 * [-r]	attribute file path
	 * [-m]	splitting mode:parameter. Splitting mode can be split (s) and cross validation (c) (default: c:5)
	 * [-a]	attribute name to perform stratified sampling (default: null)
	 * [-s]	seed of the random number generator (default: 0)
	 * </pre>
	 * 
	 * @param args the command line arguments.
	 * @throws Exception
	 */
	public static void main(String[] args) throws Exception {
		Options opts = new Options();
		CmdLineParser parser = new CmdLineParser(InstancesSplitter.class, opts);
		String[] data = null;
		try {
			parser.parse(args);
			data = opts.crossValidationMode.split(":");
			if (data.length < 2) {
				throw new IllegalArgumentException();
			}
		} catch (IllegalArgumentException e) {
			parser.printUsage();
			System.exit(1);
		}

		Random.getInstance().setSeed(opts.seed);

		Instances instances = InstancesReader.read(opts.attPath, opts.inputPath);

		File attFile = new File(opts.attPath);
		String prefix = attFile.getName().split("\\.")[0];

		File dir = new File(opts.outputDirPath);
		if (!dir.exists()) {
			dir.mkdirs();
		}

		switch (data[0]) {
			case "c":
				int k = Integer.parseInt(data[1]);
				if (data.length == 2) {
					Instances[][] folds = InstancesSplitter.createCrossValidationFolds(instances, opts.attToStrafity, k);
					for (int i = 0; i < folds.length; i++) {
						String path = opts.outputDirPath + File.separator + "cv." + i;
						File directory = new File(path);
						if (!directory.exists()) {
							directory.mkdir();
						}
						InstancesWriter.write(folds[i][0], path + File.separator + prefix + ".attr", path
								+ File.separator + prefix + ".train.all");
						InstancesWriter.write(folds[i][1], path + File.separator + prefix + ".test");
					}
				} else {
					double ratio = Double.parseDouble(data[2]);
					Instances[][] folds = InstancesSplitter.createCrossValidationFolds(instances, opts.attToStrafity, k, ratio);
					for (int i = 0; i < folds.length; i++) {
						String path = opts.outputDirPath + File.separator + "cv." + i;
						File directory = new File(path);
						if (!directory.exists()) {
							directory.mkdir();
						}
						InstancesWriter.write(folds[i][0], path + File.separator + prefix + ".attr", path
								+ File.separator + prefix + ".train");
						InstancesWriter.write(folds[i][1], path + File.separator + prefix + ".valid");
						InstancesWriter.write(folds[i][2], path + File.separator + prefix + ".test");
					}
				}
				break;
			case "s":
				if (data.length == 2) {
					double ratio = Double.parseDouble(data[1]);
					Instances[] datasets = InstancesSplitter.split(instances, opts.attToStrafity, ratio);
					InstancesWriter.write(datasets[0], opts.outputDirPath + File.separator + prefix + ".attr",
							opts.outputDirPath + File.separator + prefix + ".train");
					InstancesWriter.write(datasets[1], opts.outputDirPath + File.separator + prefix + ".valid");
				} else if (data.length == 3) {
					double ratioTrain = Double.parseDouble(data[1]);
					double ratioValid = Double.parseDouble(data[2]);
					double[] ratios = new double[] {
							ratioTrain,
							ratioValid
					};
					Instances[] datasets = InstancesSplitter.split(instances, opts.attToStrafity, ratios);
					InstancesWriter.write(datasets[0], opts.outputDirPath + File.separator + prefix + ".attr",
							opts.outputDirPath + File.separator + prefix + ".train");
					InstancesWriter.write(datasets[1], opts.outputDirPath + File.separator + prefix + ".valid");
				} else if (data.length == 4) {
					double ratioTrain = Double.parseDouble(data[1]);
					double ratioValid = Double.parseDouble(data[2]);
					double ratioTest = Double.parseDouble(data[3]);
					double[] ratios = new double[] {
							ratioTrain,
							ratioValid,
							ratioTest
					};
					Instances[] datasets = InstancesSplitter.split(instances, opts.attToStrafity, ratios);
					InstancesWriter.write(datasets[0], opts.outputDirPath + File.separator + prefix + ".attr",
							opts.outputDirPath + File.separator + prefix + ".train");
					InstancesWriter.write(datasets[1], opts.outputDirPath + File.separator + prefix + ".valid");
					InstancesWriter.write(datasets[2], opts.outputDirPath + File.separator + prefix + ".test");
				} else {
					double[] ratios = new double[data.length - 1];
					for (int i = 0; i < ratios.length; i++) {
						ratios[i] = Double.parseDouble(data[i + 1]);
					}
					Instances[] datasets = InstancesSplitter.split(instances, opts.attToStrafity, ratios);
					for (int i = 0; i < datasets.length; i++) {
						InstancesWriter.write(datasets[i], opts.outputDirPath + File.separator + prefix + ".data." + i);
					}
				}
				break;
			default:
				break;
		}
	}

	/**
	 * Creates cross validation folds from a dataset. For each cross validation fold contains a training set and a test
	 * set.
	 * 
	 * @param instances the dataset.
	 * @param k the number of cross validation folds.
	 * @return the cross validation datasets.
	 */
	public static Instances[][] createCrossValidationFolds(Instances instances, int k) {
		Instances[] datasets = split(instances, k);
		Instances[][] folds = new Instances[k][2];
		for (int i = 0; i < k; i++) {
			folds[i][1] = datasets[i];
			folds[i][0] = new Instances(instances.getAttributes(), instances.getTargetAttribute());
			for (int j = 0; j < k; j++) {
				if (i == j) {
					continue;
				}
				for (Instance instance : datasets[j]) {
					folds[i][0].add(instance);
				}
			}
		}
		return folds;
	}

	/**
	 * Creates cross validation folds from a dataset. For each cross validation fold contains a training set, a
	 * validation set and a test set.
	 * 
	 * @param instances the dataset.
	 * @param k the number of cross validation folds.
	 * @param ratio the ratio that controls how many points in the training set for each fold.
	 * @return the cross validation datasets.
	 */
	public static Instances[][] createCrossValidationFolds(Instances instances, int k, double ratio) {
		Instances[] datasets = split(instances, k);
		Instances[][] folds = new Instances[k][3];
		for (int i = 0; i < k; i++) {
			folds[i][2] = datasets[i];
			Instances trainSet = new Instances(instances.getAttributes(), instances.getTargetAttribute());
			for (int j = 0; j < k; j++) {
				if (i == j) {
					continue;
				}
				for (Instance instance : datasets[j]) {
					trainSet.add(instance);
				}
			}
			Instances[] tmp = split(trainSet, ratio);
			folds[i][0] = tmp[0];
			folds[i][1] = tmp[1];
		}
		return folds;
	}
	
	/**
	 * Creates cross validation folds from a dataset. For each cross validation fold contains a training set and a test
	 * set.
	 * 
	 * @param instances the dataset.
	 * @param attToStratify the attribute to perform stratified sampling.
	 * @param k the number of cross validation folds.
	 * @return the cross validation datasets.
	 */
	public static Instances[][] createCrossValidationFolds(Instances instances, String attToStratify, int k) {
		Instances[] datasets = split(instances, attToStratify, k);
		Instances[][] folds = new Instances[k][2];
		for (int i = 0; i < k; i++) {
			folds[i][1] = datasets[i];
			folds[i][0] = new Instances(instances.getAttributes(), instances.getTargetAttribute());
			for (int j = 0; j < k; j++) {
				if (i == j) {
					continue;
				}
				for (Instance instance : datasets[j]) {
					folds[i][0].add(instance);
				}
			}
		}
		return folds;
	}
	
	/**
	 * Creates cross validation folds from a dataset. For each cross validation fold contains a training set, a
	 * validation set and a test set.
	 * 
	 * @param instances the dataset.
	 * @param attToStratify the attribute to perform stratified sampling.
	 * @param k the number of cross validation folds.
	 * @param ratio the ratio that controls how many points in the training set for each fold.
	 * @return the cross validation datasets.
	 */
	public static Instances[][] createCrossValidationFolds(Instances instances, String attToStratify, int k, double ratio) {
		Instances[] datasets = split(instances, attToStratify, k);
		Instances[][] folds = new Instances[k][3];
		for (int i = 0; i < k; i++) {
			folds[i][2] = datasets[i];
			Instances trainSet = new Instances(instances.getAttributes(), instances.getTargetAttribute());
			for (int j = 0; j < k; j++) {
				if (i == j) {
					continue;
				}
				for (Instance instance : datasets[j]) {
					trainSet.add(instance);
				}
			}
			Instances[] tmp = split(trainSet, attToStratify, ratio);
			folds[i][0] = tmp[0];
			folds[i][1] = tmp[1];
		}
		return folds;
	}

	/**
	 * Splits the dataset according to the ratios. This method returns multiple instances objects, the size of each
	 * partition is determined by the ratios array. The sum of ratios can be smaller than 1.
	 * 
	 * @param instances the dataset.
	 * @param ratios the ratios.
	 * @return partitions of the dataset.
	 */
	public static Instances[] split(Instances instances, double... ratios) {
		if (StatUtils.sum(ratios) > 1) {
			throw new IllegalArgumentException("Sum of ratios is larger than 1");
		}
		Instances dataset = new Instances(instances);
		dataset.shuffle(Random.getInstance().getRandom());
		Instances[] datasets = new Instances[ratios.length];
		for (int i = 0; i < datasets.length; i++) {
			datasets[i] = new Instances(dataset.getAttributes(), dataset.getTargetAttribute());
		}
		double sumRatios = StatUtils.sum(ratios);
		int n = 0;
		for (int k = 0; k < datasets.length; k++) {
			int m = (int) (dataset.size() * ratios[k]);
			if (k == datasets.length - 1 && MathUtils.equals(sumRatios, 1.0)) {
				m = dataset.size() - n;
			}
			Instances partition = datasets[k];
			for (int i = n; i < n + m; i++) {
				partition.add(dataset.get(i));
			}
			n += m;
		}
		return datasets;
	}
	
	/**
	 * Splits the dataset according to the ratio. This method returns two instances objects, the size of the first one
	 * is 100% * ratio of the orignal dataset while the size of the second one is 100% * (1 - ratio) of the orignal
	 * dataset.
	 * 
	 * @param instances the dataset.
	 * @param ratio the ratio.
	 * @return two smaller datasets.
	 */
	public static Instances[] split(Instances instances, double ratio) {
		return split(instances, new double[] { ratio, 1 - ratio });
	}
	
	/**
	 * Splits the dataset into k equi-sized datasets.
	 * 
	 * @param instances the dataset.
	 * @param k the number of datasets to return.
	 * @return k equi-sized datasets.
	 */
	public static Instances[] split(Instances instances, int k) {
		Instances dataset = new Instances(instances);
		dataset.shuffle(Random.getInstance().getRandom());
		Instances[] datasets = new Instances[k];
		for (int i = 0; i < datasets.length; i++) {
			datasets[i] = new Instances(dataset.getAttributes(), dataset.getTargetAttribute());
		}
		for (int i = 0; i < dataset.size(); i++) {
			datasets[i % datasets.length].add(dataset.get(i));
		}
		return datasets;
	}

	/**
	 * Splits the dataset according to the ratio. This method returns two instances objects, the size of the first one
	 * is 100% * ratio of the orignal dataset while the size of the second one is 100% * (1 - ratio) of the orignal
	 * dataset.
	 * 
	 * @param instances the dataset.
	 * @param attToStratify the attribute to perform stratified sampling.
	 * @param ratio the ratio.
	 * @return two smaller datasets.
	 */
	public static Instances[] split(Instances instances, String attToStratify, double ratio) {
		return split(instances, attToStratify, new double[] { ratio, 1 - ratio });
	}

	/**
	 * Splits the dataset according to the ratios. This method returns multiple instances objects, the size of each
	 * partition is determined by the ratios array. The sum of ratios can be smaller than 1.
	 * 
	 * @param instances the dataset.
	 * @param attToStratify the attribute to perform stratified sampling.
	 * @param ratios the ratios.
	 * @return partitions of the dataset.
	 */
	public static Instances[] split(Instances instances, String attToStratify, double... ratios) {
		if (attToStratify == null) {
			return split(instances, ratios);
		}
		List<List<Instance>> strata = getStrata(instances, attToStratify);
		if (strata == null) {
			return split(instances, ratios);
		}
		Instances[] datasets = new Instances[ratios.length];
		for (int i = 0; i < datasets.length; i++) {
			datasets[i] = new Instances(instances.getAttributes(), instances.getTargetAttribute());
		}
		double sumRatios = StatUtils.sum(ratios);
		for (List<Instance> list : strata) {
			int n = 0;
			for (int k = 0; k < datasets.length; k++) {
				int m = (int) (list.size() * ratios[k]);
				if (k == datasets.length -1 && MathUtils.equals(sumRatios, 1.0)) {
					m = list.size() - n;
				}
				Instances partition = datasets[k];
				for (int i = n; i < n + m; i++) {
					partition.add(list.get(i));
				}
				n += m;
			}
		}
		return datasets;
	}

	/**
	 * Splits the dataset into k equi-sized datasets.
	 * 
	 * @param instances the dataset.
	 * @param attToStratify the attribute to perform stratified sampling.
	 * @param k the number of datasets to return.
	 * @return k equi-sized datasets.
	 */
	public static Instances[] split(Instances instances, String attToStratify, int k) {
		if (attToStratify == null) {
			return split(instances, k);
		}
		List<List<Instance>> strata = getStrata(instances, attToStratify);
		if (strata == null) {
			return split(instances, k);
		}
		Instances[] datasets = new Instances[k];
		for (int i = 0; i < datasets.length; i++) {
			datasets[i] = new Instances(instances.getAttributes(), instances.getTargetAttribute());
		}
		for (List<Instance> stratum : strata) {
			for (int i = 0; i < stratum.size(); i++) {
				datasets[i % datasets.length].add(stratum.get(i));
			}
		}
		return datasets;
	}
	
	private static List<List<Instance>> getStrata(Instances instances, String attToStratify) {
		List<List<Instance>> lists = new ArrayList<>();
		Instances dataset = new Instances(instances);
		dataset.shuffle(Random.getInstance().getRandom());
		if (instances.getTargetAttribute().getName().equals(attToStratify)) {
			Attribute targetAtt = instances.getTargetAttribute();
			if (targetAtt == null || targetAtt.getType() == Type.NUMERIC) {
				return null;
			}
			int cardinality = 0;
			if (targetAtt.getType() == Type.BINNED) {
				cardinality = ((BinnedAttribute) targetAtt).getNumBins();
			} else {
				cardinality = ((NominalAttribute) targetAtt).getCardinality();
			}
			for (int i = 0; i < cardinality; i++) {
				lists.add(new ArrayList<Instance>());
			}
			for (Instance instance : instances) {
				int idx = (int) instance.getTarget();
				lists.get(idx).add(instance);
			}
		} else {
			List<Attribute> attributes = instances.getAttributes();
			Attribute attr = null;
			for (Attribute att : attributes) {
				if (att.getName().equals(attToStratify)) {
					attr = att;
					break;
				}
			}
			if (attr == null || attr.getType() == Type.NUMERIC) {
				return null;
			}
			int cardinality = 0;
			if (attr.getType() == Type.BINNED) {
				cardinality = ((BinnedAttribute) attr).getNumBins();
			} else {
				cardinality = ((NominalAttribute) attr).getCardinality();
			}
			for (int i = 0; i < cardinality; i++) {
				lists.add(new ArrayList<Instance>());
			}
			for (Instance instance : dataset) {
				int idx = (int) instance.getValue(attr);
				lists.get(idx).add(instance);
			}
		}
		
		return lists;
	}

}


================================================
FILE: src/main/java/mltk/core/processor/OneHotEncoder.java
================================================
package mltk.core.processor;

import java.util.ArrayList;
import java.util.List;

import mltk.core.Attribute;
import mltk.core.BinnedAttribute;
import mltk.core.Instance;
import mltk.core.Instances;
import mltk.core.NominalAttribute;
import mltk.core.NumericalAttribute;

/**
 * Class for one-hot encoders. Binned attributes and nominal attributes are
 * transformed into a set of binary attributes using one-hot encoding. 
 * 
 * @author Yin Lou
 *
 */
public class OneHotEncoder {

	/**
	 * Transforms all binned and nominal attributes to binary attributes using
	 * one-hot encoding.
	 * 
	 * @param instances the input instances.
	 * @return the transformed instances.
	 */
	public Instances process(Instances instances) {
		List<Attribute> attrListOld = instances.getAttributes();
		List<Attribute> attrListNew = new ArrayList<>();
		int[] offset = new int[instances.dimension()];
		boolean[] isNumerical = new boolean[instances.dimension()];
		int attIndex = 0;
		for (int j = 0; j < attrListOld.size(); j++) {
			Attribute attribute = attrListOld.get(j);
			offset[j] = attIndex;
			String name = attribute.getName();
			if (attribute instanceof BinnedAttribute) {
				BinnedAttribute binnedAttribute = (BinnedAttribute) attribute;
				int size = binnedAttribute.getNumBins();
				for (int k = 0; k < size; k++) {
					NumericalAttribute attr = new NumericalAttribute(name + "_" + k);
					attr.setIndex(attIndex++);
					attrListNew.add(attr);
				}
			} else if (attribute instanceof NominalAttribute) {
				NominalAttribute nominalAttribute = (NominalAttribute) attribute;
				String[] states = nominalAttribute.getStates();
				for (String state : states) {
					NumericalAttribute attr = new NumericalAttribute(name + "_" + state);
					attr.setIndex(attIndex++);
					attrListNew.add(attr);
				}
			} else {
				NumericalAttribute attr = new NumericalAttribute(name);
				attr.setIndex(attIndex++);
				attrListNew.add(attr);
				isNumerical[j] = true;
			}
		}
		
		Instances instancesNew = new Instances(attrListNew, instances.getTargetAttribute(), 
				instances.size());
		for (Instance instance : instances) {
			int[] indices = new int[instances.dimension()];
			double[] values = new double[instances.dimension()];
			for (int j = 0; j < attrListOld.size(); j++) {
				if (isNumerical[j]) {
					indices[j] = offset[j];
					values[j] = instance.getValue(attrListOld.get(j));
				} else {
					int v = (int) instance.getValue(attrListOld.get(j));
					indices[j] = offset[j] + v;
					values[j] = 1.0;
				}
			}
			Instance instanceNew = new Instance(indices, values, instance.getTarget(), 
					instance.getWeight());
			instancesNew.add(instanceNew);	
		}
		
		return instancesNew;
	}
	
}


================================================
FILE: src/main/java/mltk/core/processor/package-info.java
================================================
/**
 * Provides classes for processing datasets.
 */
package mltk.core.processor;

================================================
FILE: src/main/java/mltk/feature/selection/BackwardElimination.java
================================================
package mltk.feature.selection;

import java.util.ArrayList;
import java.util.List;

import mltk.core.Attribute;
import mltk.core.Instances;
import mltk.predictor.BaggedEnsembleLearner;
import mltk.predictor.Regressor;
import mltk.predictor.evaluation.Evaluator;
import mltk.predictor.tree.ensemble.ag.AdditiveGrovesLearner;
import mltk.util.StatUtils;
import mltk.util.tuple.DoublePair;
import mltk.util.tuple.Pair;

/**
 * Class for feature selection using backward elimination.
 * 
 * @author Yin Lou
 * 
 */
public class BackwardElimination {

	/**
	 * Selects features using backward elimination.
	 * 
	 * @param trainSet the training set.
	 * @param validSet the validation set.
	 * @param learner the learner to use.
	 * @param numIters the number of iterations to estimate the mean and std for full complexity models.
	 * @return the list of selected features and &lt;mean, std$gt; pair for full complexity models.
	 */
	public static Pair<List<Attribute>, DoublePair> select(Instances trainSet, Instances validSet,
			BaggedEnsembleLearner learner, int numIters) {
		List<Attribute> attributes = trainSet.getAttributes();
		List<Attribute> selected = new ArrayList<>(attributes);
		DoublePair perf = null;
		for (;;) {
			if (selected.size() == 0) {
				break;
			}
			boolean changed = false;
			trainSet.setAttributes(selected);
			perf = evaluateModel(trainSet, validSet, learner, numIters);
			System.out.println("Mean: " + perf.v1 + " Std: " + perf.v2);
			int i;
			for (i = 0; i < selected.size();) {
				List<Attribute> attList = new ArrayList<>(selected);
				Attribute attr = attList.get(i);
				attList.remove(i);
				trainSet.setAttributes(attList);
				Regressor regressor = (Regressor) learner.build(trainSet);
				double rmse = Evaluator.evalRMSE(regressor, validSet);
				System.out.println("Testing: " + attr.getName() + " RMSE: " + rmse);
				if (perf.v1 - perf.v2 * 3 <= rmse && rmse <= perf.v1 + perf.v2 * 3) {
					// Eliminate feature
					selected.remove(i);
					changed = true;
					System.out.println("Eliminate: " + attr.getName());
				} else {
					i++;
				}
			}
			if (!changed) {
				break;
			}
		}
		trainSet.setAttributes(attributes);
		return new Pair<List<Attribute>, DoublePair>(selected, perf);
	}

	/**
	 * Selects features using backward elimination in Additive Groves.
	 * 
	 * @param trainSet the training set.
	 * @param validSet the validation set.
	 * @param learner the learner to use.
	 * @param baggingIters the number of bagging iterations.
	 * @param numTrees the number of trees in a grove.
	 * @param alpha the alpha.
	 * @param numIters the number of iterations to estimate the mean and std for full complexity models.
	 * @return the list of selected features and $lt;mean, std$gt; pair for full complexity models.
	 */
	public static Pair<List<Attribute>, DoublePair> select(Instances trainSet, Instances validSet,
			AdditiveGrovesLearner learner, int baggingIters, int numTrees, double alpha, int numIters) {
		List<Attribute> attributes = trainSet.getAttributes();
		List<Attribute> selected = new ArrayList<>(attributes);
		DoublePair perf = null;
		for (;;) {
			if (selected.size() == 0) {
				break;
			}
			boolean changed = false;
			trainSet.setAttributes(selected);
			perf = evaluateModel(trainSet, validSet, learner, baggingIters, numTrees, alpha, numIters);
			System.out.println("Mean: " + perf.v1 + " Std: " + perf.v2);
			int i;
			for (i = 0; i < selected.size();) {
				List<Attribute> attList = new ArrayList<>(selected);
				Attribute attr = attList.get(i);
				System.out.println("Testing: " + attr.getName());
				attList.remove(i);
				trainSet.setAttributes(attList);
				Regressor regressor = learner.runLayeredTraining(trainSet,baggingIters, numTrees, alpha);
				double rmse = Evaluator.evalRMSE(regressor, validSet);
				System.out.println("Testing: " + attr.getName() + " RMSE: " + rmse);
				if (perf.v1 - perf.v2 * 3 <= rmse && rmse <= perf.v1 + perf.v2 * 3) {
					// Eliminate feature
					selected.remove(i);
					changed = true;
					System.out.println("Eliminate: " + attr.getName());
				} else {
					i++;
				}
			}
			if (!changed) {
				break;
			}
		}
		trainSet.setAttributes(attributes);
		return new Pair<List<Attribute>, DoublePair>(selected, perf);
	}

	private static DoublePair evaluateModel(Instances trainSet, Instances validSet, BaggedEnsembleLearner learner,
			int numIters) {
		// Estimating std of full complexity model
		double[] rmse = new double[numIters];
		for (int i = 0; i < rmse.length; i++) {
			Regressor regressor = (Regressor) learner.build(trainSet);
			rmse[i] = Evaluator.evalRMSE(regressor, validSet);
		}
		double mean = StatUtils.mean(rmse);
		double std = StatUtils.sd(rmse);
		return new DoublePair(mean, std);
	}

	private static DoublePair evaluateModel(Instances trainSet, Instances validSet, AdditiveGrovesLearner learner,
			int baggingIters, int numTrees, double alpha, int numIters) {
		// Estimating std of full complexity model
		double[] rmse = new double[numIters];
		for (int i = 0; i < rmse.length; i++) {
			Regressor regressor = learner.runLayeredTraining(trainSet, baggingIters, numTrees, alpha);
			rmse[i] = Evaluator.evalRMSE(regressor, validSet);
			System.out.println("\tEvaluating model " + (i + 1) + " / " + numIters + "\t" + rmse[i]);
		}
		double mean = StatUtils.mean(rmse);
		double std = StatUtils.sd(rmse);
		return new DoublePair(mean, std);
	}

}


================================================
FILE: src/main/java/mltk/feature/selection/package-info.java
================================================
/**
 * Contains classes for feature selection.
 */
package mltk.feature.selection;

================================================
FILE: src/main/java/mltk/predictor/BaggedEnsemble.java
================================================
package mltk.predictor;

import java.util.HashMap;
import java.util.Map;

import mltk.core.Instance;

/**
 * Class for bagged ensembles.
 * 
 * @author Yin Lou
 * 
 */
public class BaggedEnsemble extends Ensemble {

	/**
	 * Constructor.
	 */
	public BaggedEnsemble() {
		super();
	}

	/**
	 * Constructor.
	 * 
	 * @param capacity the capacity of this bagged ensemble.
	 */
	public BaggedEnsemble(int capacity) {
		super(capacity);
	}

	@Override
	public double regress(Instance instance) {
		if (predictors.size() == 0) {
			return 0.0;
		} else {
			double prediction = 0.0;
			for (Predictor predictor : predictors) {
				Regressor regressor = (Regressor) predictor;
				prediction += regressor.regress(instance);
			}
			return prediction / predictors.size();
		}
	}

	@Override
	public int classify(Instance instance) {
		if (predictors.size() == 0) {
			// Default: return first class
			return 0;
		} else {
			Map<Integer, Integer> votes = new HashMap<>();
			for (Predictor predictor : predictors) {
				Classifier classifier = (Classifier) predictor;
				int cls = (int) classifier.classify(instance);
				if (!votes.containsKey(cls)) {
					votes.put(cls, 0);
				}
				votes.put(cls, votes.get(cls) + 1);
			}
			int prediction = 0;
			int maxVotes = 0;
			for (int cls : votes.keySet()) {
				int numVotes = votes.get(cls);
				if (numVotes > maxVotes) {
					maxVotes = numVotes;
					prediction = cls;
				}
			}
			return prediction;
		}
	}

	@Override
	public BaggedEnsemble copy() {
		BaggedEnsemble copy = new BaggedEnsemble(predictors.size());
		for (Predictor predictor : predictors) {
			copy.add(predictor.copy());
		}
		return copy;
	}

}


================================================
FILE: src/main/java/mltk/predictor/BaggedEnsembleLearner.java
================================================
package mltk.predictor;

import mltk.core.Instances;
import mltk.core.Sampling;

/**
 * Class for learning bagged ensembles.
 * 
 * @author Yin Lou
 * 
 */
public class BaggedEnsembleLearner extends Learner {

	protected int baggingIters;
	protected Learner learner;
	protected Instances[] bags;

	/**
	 * Constructor.
	 * 
	 * @param baggingIters the number of bagging iterations.
	 * @param learner the learner.
	 */
	public BaggedEnsembleLearner(int baggingIters, Learner learner) {
		this.baggingIters = baggingIters;
		this.learner = learner;
	}

	/**
	 * Returns the number of bagging iterations.
	 * 
	 * @return the number of bagging iterations.
	 */
	public int getBaggingIterations() {
		return baggingIters;
	}

	/**
	 * Sets the number of bagging iterations.
	 * 
	 * @param baggingIters the number of bagging iterations.
	 */
	public void setBaggingIterations(int baggingIters) {
		this.baggingIters = baggingIters;
	}

	/**
	 * Returns the learner.
	 * 
	 * @return the learner.
	 */
	public Learner getLearner() {
		return learner;
	}

	/**
	 * Sets the learner.
	 * 
	 * @param learner the learner.
	 */
	public void setLearner(Learner learner) {
		this.learner = learner;
	}

	/**
	 * Returns the bootstrap samples.
	 * 
	 * @return the bootstrap samples.
	 */
	public Instances[] getBags() {
		return bags;
	}

	/**
	 * Sets the bootstrap samples.
	 * 
	 * @param bags the bootstrap samples.
	 */
	public void setBags(Instances[] bags) {
		this.bags = bags;
	}

	@Override
	public BaggedEnsemble build(Instances instances) {
		// Create bags
		bags = Sampling.createBags(instances, baggingIters);

		BaggedEnsemble baggedEnsemble = new BaggedEnsemble(bags.length);
		for (Instances bag : bags) {
			baggedEnsemble.add(learner.build(bag));
		}
		return baggedEnsemble;
	}

	/**
	 * Builds a bagged ensemble.
	 * 
	 * @param bags the bootstrap samples.
	 * @return a bagged ensemble.
	 */
	public BaggedEnsemble build(Instances[] bags) {
		BaggedEnsemble baggedEnsemble = new BaggedEnsemble(bags.length);
		for (Instances bag : bags) {
			baggedEnsemble.add(learner.build(bag));
		}
		return baggedEnsemble;
	}

}


================================================
FILE: src/main/java/mltk/predictor/BoostedEnsemble.java
================================================
package mltk.predictor;

import mltk.core.Instance;

/**
 * Class for boosted ensembles.
 * 
 * @author Yin Lou
 * 
 */
public class BoostedEnsemble extends Ensemble {

	/**
	 * Constructor.
	 */
	public BoostedEnsemble() {
		super();
	}

	/**
	 * Constructor.
	 * 
	 * @param capacity the capacity of the boosted ensemble.
	 */
	public BoostedEnsemble(int capacity) {
		super(capacity);
	}

	@Override
	public double regress(Instance instance) {
		double prediction = 0.0;
		for (Predictor predictor : predictors) {
			Regressor regressor = (Regressor) predictor;
			prediction += regressor.regress(instance);
		}
		return prediction;
	}

	@Override
	public int classify(Instance instance) {
		double pred = regress(instance);
		if (pred >= 0) {
			return 1;
		} else {
			return -1;
		}
	}

	/**
	 * Removes a particular predictor.
	 * 
	 * @param index the index of the predictor to remove.
	 */
	public void remove(int index) {
		predictors.remove(index);
	}

	/**
	 * Removes the last predictor.
	 */
	public void removeLast() {
		if (predictors.size() > 0) {
			predictors.remove(predictors.size() - 1);
		}
	}

	@Override
	public BoostedEnsemble copy() {
		BoostedEnsemble copy = new BoostedEnsemble(predictors.size());
		for (Predictor predictor : predictors) {
			copy.add(predictor.copy());
		}
		return copy;
	}

}


================================================
FILE: src/main/java/mltk/predictor/Classifier.java
================================================
package mltk.predictor;

import mltk.core.Instance;

/**
 * Interface for classfiers.
 * 
 * @author Yin Lou
 * 
 */
public interface Classifier extends Predictor {

	/**
	 * Classifies an instance.
	 * 
	 * @param instance the instance to classify.
	 * @return a classified value.
	 */
	public int classify(Instance instance);

}


================================================
FILE: src/main/java/mltk/predictor/Ensemble.java
================================================
package mltk.predictor;

import java.io.BufferedReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

/**
 * Abstract class for ensembles.
 * 
 * @author Yin Lou
 * 
 */
public abstract class Ensemble implements Classifier, Regressor {

	protected List<Predictor> predictors;

	/**
	 * Constructor.
	 */
	public Ensemble() {
		predictors = new ArrayList<>();
	}

	/**
	 * Constructor.
	 * 
	 * @param capacity the capacity of this ensemble.
	 */
	public Ensemble(int capacity) {
		predictors = new ArrayList<>(capacity);
	}

	/**
	 * Returns a particular predictor.
	 * 
	 * @param index the index of predictor.
	 * @return a particular predictor.
	 */
	public Predictor get(int index) {
		return predictors.get(index);
	}

	/**
	 * Returns the internal predictors.
	 * 
	 * @return the internal predictors.
	 */
	public List<Predictor> getPredictors() {
		return predictors;
	}

	/**
	 * Adds a new predictor to the ensemble.
	 * 
	 * @param predictor the new predictor.
	 */
	public void add(Predictor predictor) {
		predictors.add(predictor);
	}

	/**
	 * Returns the size of this ensemble.
	 * 
	 * @return the size of this ensemble.
	 */
	public int size() {
		return predictors.size();
	}

	/**
	 * Clears this ensemble.
	 */
	public void clear() {
		predictors.clear();
	}

	@Override
	public void read(BufferedReader in) throws Exception {
		int capacity = Integer.parseInt(in.readLine().split(": ")[1]);
		predictors = new ArrayList<>(capacity);
		in.readLine();
		for (int i = 0; i < capacity; i++) {
			String line = in.readLine();
			String predictorName = line.substring(1, line.length() - 1).split(": ")[1];
			Class<?> clazz = Class.forName(predictorName);
			Predictor predictor = (Predictor) clazz.getDeclaredConstructor().newInstance();
			predictor.read(in);
			predictors.add(predictor);
			in.readLine();
		}
	}

	@Override
	public void write(PrintWriter out) throws Exception {
		out.printf("[Predictor: %s]\n", this.getClass().getCanonicalName());
		out.println("Ensemble: " + predictors.size());
		out.println();
		for (Predictor predictor : predictors) {
			predictor.write(out);
			out.println();
		}
	}

}


================================================
FILE: src/main/java/mltk/predictor/Family.java
================================================
package mltk.predictor;

/**
 * Class for response distribution family. This class is used for GLMs/GAMs.
 * 
 * @author Yin Lou
 *
 */
public enum Family {

	GAUSSIAN("gaussian", LinkFunction.IDENTITY),
	BINOMIAL("binomial", LinkFunction.LOGIT);

	/**
	 * Parses an enumeration from a string.
	 * 
	 * @param name the family name.
	 * @return a parsed distribution.
	 */
	public static Family get(String name) {
		for (Family family : Family.values()) {
			if (name.startsWith(family.name)) {
				return family;
			}
		}
		throw new IllegalArgumentException("Invalid family name: " + name);
	}
	String name;
	
	LinkFunction link;
	
	Family(String name, LinkFunction link) {
		this.name = name;
		this.link = link;
	}

	/**
	 * Returns the default link function for this family.
	 * 
	 * @return the default link function for this family.
	 */
	public LinkFunction getDefaultLinkFunction() {
		return link;
	}

	/**
	 * Returns the string representation of this family with default link function.
	 */
	public String toString() {
		return name + "(" + link + ")";
	}

}


================================================
FILE: src/main/java/mltk/predictor/HoldoutValidatedLearner.java
================================================
package mltk.predictor;

import mltk.core.Instances;
import mltk.predictor.evaluation.ConvergenceTester;
import mltk.predictor.evaluation.Metric;

/**
 * Class for holdout validated learners.
 * 
 * @author Yin Lou
 *
 */
public abstract class HoldoutValidatedLearner extends Learner {

	protected Instances validSet;
	protected Metric metric;
	protected ConvergenceTester ct;
	
	/**
	 * Constructor.
	 */
	public HoldoutValidatedLearner() {
		ct = new ConvergenceTester(-1, 0, 1.0);
	}
	
	/**
	 * Returns the validation set.
	 * 
	 * @return the validation set.
	 */
	public Instances getValidSet() {
		return validSet;
	}

	/**
	 * Sets the validation set.
	 * 
	 * @param validSet the validation set.
	 */
	public void setValidSet(Instances validSet) {
		this.validSet = validSet;
	}
	
	/**
	 * Returns the metric.
	 * 
	 * @return the metric.
	 */
	public Metric getMetric() {
		return metric;
	}

	/**
	 * Sets the metric. 
	 * 
	 * @param metric the metric.
	 */
	public void setMetric(Metric metric) {
		this.metric = metric;
	}
	
	/**
	 * Returns the convergence tester.
	 * 
	 * @return the convergence tester.
	 */
	public ConvergenceTester getConvergenceTester() {
		return ct;
	}
	
	/**
	 * Sets the convergence tester.
	 * 
	 * @param ct the convergence tester to set.
	 */
	public void setConvergenceTester(ConvergenceTester ct) {
		this.ct = ct;
	}
	
}


================================================
FILE: src/main/java/mltk/predictor/Learner.java
================================================
package mltk.predictor;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import mltk.core.Attribute;
import mltk.core.Instance;
import mltk.core.Instances;
import mltk.core.SparseVector;
import mltk.predictor.evaluation.Error;
import mltk.predictor.evaluation.Metric;
import mltk.predictor.evaluation.RMSE;
import mltk.util.MathUtils;
import mltk.util.StatUtils;
import mltk.util.VectorUtils;
import mltk.util.tuple.IntDoublePair;

/**
 * Class for learners.
 * 
 * @author Yin Lou
 * 
 */
public abstract class Learner {
	
	protected boolean verbose;

	/**
	 * Returns {@code true} if we output something during the training.
	 * 
	 * @return {@code true} if we output something during the training.
	 */
	public boolean isVerbose() {
		return verbose;
	}

	/**
	 * Sets whether we output something during the training.
	 * 
	 * @param verbose the switch if we output things during training.
	 */
	public void setVerbose(boolean verbose) {
		this.verbose = verbose;
	}
	
	/**
	 * Enumeration of learning tasks.
	 * 
	 */
	public enum Task {

		/**
		 * Classification task.
		 */
		CLASSIFICATION("classification"),
		/**
		 * Regression task.
		 */
		REGRESSION("regression");

		String task;

		Task(String task) {
			this.task = task;
		}

		/**
		 * Returns the string representation of learning tasks.
		 */
		public String toString() {
			return task;
		}

		/**
		 * Parses a task from a string.
		 * 
		 * @param name the name of the task.
		 * @return a parsed task.
		 */
		public static Task get(String name) {
			for (Task task : Task.values()) {
				if (task.task.startsWith(name)) {
					return task;
				}
			}
			throw new IllegalArgumentException("Invalid task name: " + name);
		}
		
		/**
		 * Returns the default metric for this task.
		 * 
		 * @return the default metric for this task.
		 */
		public Metric getDefaultMetric() {
			Metric metric = null;
			switch (this) {
				case CLASSIFICATION:
					metric = new Error();
					break;
				case REGRESSION:
					metric = new RMSE();
					break;
				default:
					break;
			}
			return metric;
		}

	}

	/**
	 * Builds a predictor from training set.
	 * 
	 * @param instances the training set.
	 * @return a predictior.
	 */
	public abstract Predictor build(Instances instances);

	/**
	 * Returns {@code true} if the instances are treated as sparse.
	 * 
	 * @param instances the instances to test.
	 * @return {@code true} if the instances are treated as sparse.
	 */
	protected boolean isSparse(Instances instances) {
		int numSparseInstances = 0;
		for (Instance instance : instances) {
			if (instance.isSparse()) {
				numSparseInstances++;
			}
		}
		return numSparseInstances > instances.size() / 2;
	}

	/**
	 * Returns the column-oriented format of sparse dataset. This method automatically removes attributes with
	 * close-to-zero variance.
	 * 
	 * @param instances the instances.
	 * @param normalize {@code true} if all the columns are normalized.
	 * @return the column-oriented format of sparse dataset.
	 */
	protected SparseDataset getSparseDataset(Instances instances, boolean normalize) {
		List<Attribute> attributes = instances.getAttributes();
		int maxAttrId = attributes.get(attributes.size() - 1).getIndex();
		boolean[] included = new boolean[maxAttrId + 1];
		for (Attribute attribute : attributes) {
			included[attribute.getIndex()] = true;
		}

		final int n = instances.size();
		Map<Integer, List<IntDoublePair>> map = new TreeMap<>();
		double[] y = new double[n];

		for (int i = 0; i < instances.size(); i++) {
			Instance instance = instances.get(i);
			SparseVector vector = (SparseVector) instance.getVector();
			int[] indices = vector.getIndices();
			double[] values = vector.getValues();
			for (int j = 0; j < indices.length; j++) {
				if (included[indices[j]]) {
					if (!map.containsKey(indices[j])) {
						map.put(indices[j], new ArrayList<IntDoublePair>());
					}
					List<IntDoublePair> list = map.get(indices[j]);
					list.add(new IntDoublePair(i, values[j]));
				}
			}
			y[i] = instance.getTarget();
		}

		List<Integer> attrsList = new ArrayList<>(map.size());
		List<int[]> indicesList = new ArrayList<>(map.size());
		List<double[]> valuesList = new ArrayList<>(map.size());
		List<Double> stdList = new ArrayList<>(map.size());
		List<Double> cList = null;
		if (normalize) {
			cList = new ArrayList<>();
		}
		double factor = Math.sqrt(n);
		for (Map.Entry<Integer, List<IntDoublePair>> entry : map.entrySet()) {
			Integer attr = entry.getKey();
			List<IntDoublePair> list = entry.getValue();
			int[] indices = new int[list.size()];
			double[] values = new double[list.size()];
			for (int i = 0; i < list.size(); i++) {
				IntDoublePair pair = list.get(i);
				indices[i] = pair.v1;
				values[i] = pair.v2;
			}
			double std = StatUtils.sd(values, n);
			if (std > MathUtils.EPSILON) {
				attrsList.add(attr);
				indicesList.add(indices);
				valuesList.add(values);
				stdList.add(std);
				if (normalize) {
					// Normalize the data
					double c = factor / std;
					VectorUtils.multiply(values, c);
					cList.add(c);
				}
			}
		}

		final int p = attrsList.size();
		int[] attrs = new int[p];
		int[][] indices = new int[p][];
		double[][] values = new double[p][];
		for (int j = 0; j < p; j++) {
			attrs[j] = attrsList.get(j);
			indices[j] = indicesList.get(j);
			values[j] = valuesList.get(j);
		}
		
		double[] std = new double[stdList.size()];
		for (int j = 0; j < std.length; j++) {
			std[j] = stdList.get(j);
		}
		double[] c = null;
		if (cList != null) {
			c = new double[cList.size()];
			for (int j = 0; j < c.length; j++) {
				c[j] = cList.get(j);
			}
		}

		return new SparseDataset(attrs, indices, values, y, std, c);
	}

	/**
	 * Returns the column-oriented format of dense dataset. This method automatically removes attributes with
	 * close-to-zero variance.
	 * 
	 * @param instances the instances.
	 * @param normalize {@code true} if all the columns are normalized.
	 * @return the column-oriented format of dense dataset.
	 */
	protected DenseDataset getDenseDataset(Instances instances, boolean normalize) {
		List<Attribute> attributes = instances.getAttributes();
		final int p = instances.dimension();
		final int n = instances.size();

		// Convert to column oriented format
		List<double[]> xList = new ArrayList<>(p);
		double[] y = new double[n];
		for (int i = 0; i < n; i++) {
			y[i] = instances.get(i).getTarget();
		}

		List<Integer> attrsList = new ArrayList<>(p);
		List<Double> stdList = new ArrayList<>(p);
		List<Double> cList = null;
		if (normalize) {
			cList = new ArrayList<>();
		}
		double factor = Math.sqrt(n);
		for (int j = 0; j < p; j++) {
			int attIndex = attributes.get(j).getIndex();
			double[] x = new double[n];
			for (int i = 0; i < n; i++) {
				x[i] = instances.get(i).getValue(attIndex);
			}
			double std = StatUtils.sd(x);
			if (std > MathUtils.EPSILON) {
				attrsList.add(attIndex);
				xList.add(x);
				stdList.add(std);
				if (normalize) {
					// Normalize the data
					double c = factor / std;
					VectorUtils.multiply(x, c);
					cList.add(c);
				}
			}
		}

		int[] attrs = new int[attrsList.size()];
		double[][] x = new double[attrsList.size()][];
		for (int j = 0; j < attrs.length; j++) {
			attrs[j] = attrsList.get(j);
			x[j] = xList.get(j);
		}
		
		double[] std = new double[stdList.size()];
		for (int j = 0; j < std.length; j++) {
			std[j] = stdList.get(j);
		}
		double[] c = null;
		if (cList != null) {
			c = new double[cList.size()];
			for (int j = 0; j < c.length; j++) {
				c[j] = cList.get(j);
			}
		}

		return new DenseDataset(attrs, x, y, std, c);
	}

	/**
	 * Class for sparse dataset.
	 *
	 */
	protected class SparseDataset {

		public int[] attrs;
		public int[][] indices;
		public double[][] values;
		public double[] y;
		public double[] stdList;
		public double[] cList;

		SparseDataset(int[] attrs, int[][] indices, double[][] values, double[] y, double[] stdList,
				double[] cList) {
			this.attrs = attrs;
			this.indices = indices;
			this.values = values;
			this.y = y;
			this.stdList = stdList;
			this.cList = cList;
		}

	}

	/**
	 * Class for dense dataset.
	 *
	 */
	protected class DenseDataset {

		public int[] attrs;
		public double[][] x;
		public double[] y;
		public double[] stdList;
		public double[] cList;

		DenseDataset(int[] attrs, double[][] x, double[] y, double[] stdList, double[] cList) {
			this.attrs = attrs;
			this.x = x;
			this.y = y;
			this.stdList = stdList;
			this.cList = cList;
		}

	}

}


================================================
FILE: src/main/java/mltk/predictor/LinkFunction.java
================================================
package mltk.predictor;

import mltk.util.MathUtils;

/**
 * Class for link functions.
 * 
 * @author Yin Lou
 *
 */
public enum LinkFunction {
	
	IDENTITY("identity"),
	LOGIT("logit");
	
	/**
	 * Parses a link function from a string.
	 * 
	 * @param name the name of the function.
	 * @return a parsed link function.
	 */
	public static LinkFunction get(String name) {
		for (LinkFunction link : LinkFunction.values()) {
			if (link.name.startsWith(name)) {
				return link;
			}
		}
		throw new IllegalArgumentException("Unknown link function: " + name);
	}
	
	String name;
	
	LinkFunction(String name) {
		this.name = name;
	}
	
	/**
	 * Applies the inverse of this link function.
	 * 
	 * @param x the argument.
	 * @return the inverse of this link function.
	 */
	public double applyInverse(double x) {
		double r = 0;
		switch (this) {
			case IDENTITY:
				r = x;
				break;
			case LOGIT:
				r = MathUtils.sigmoid(x);
				break;
			default:
				break;
		}
		return r;
	}
	
	/**
	 * Returns the string representation of this link function.
	 */
	public String toString() {
		return name;
	}
	
}


================================================
FILE: src/main/java/mltk/predictor/Predictor.java
================================================
package mltk.predictor;

import java.io.BufferedReader;
import java.io.PrintWriter;

import mltk.core.Copyable;
import mltk.core.Writable;

/**
 * Interface for predictors.
 * 
 * @author Yin Lou
 * 
 */
public interface Predictor extends Writable, Copyable<Predictor> {
	
	/**
	 * Reads in this predictor. This method is used in {@link mltk.predictor.io.PredictorReader}.
	 * 
	 * @param in the reader.
	 * @throws Exception
	 */
	public void read(BufferedReader in) throws Exception;

	/**
	 * Writes this predictor. This method is used in {@link mltk.predictor.io.PredictorWriter}.
	 * 
	 * @param out the writer.
	 * @throws Exception
	 */
	public void write(PrintWriter out) throws Exception;

}


================================================
FILE: src/main/java/mltk/predictor/ProbabilisticClassifier.java
================================================
package mltk.predictor;

import mltk.core.Instance;

/**
 * Interface for classifiers that predicts the class probabilities.
 * 
 * @author Yin Lou
 * 
 */
public interface ProbabilisticClassifier extends Classifier {

	/**
	 * Returns the class probabilities.
	 * 
	 * @param instance the instance to predict.
	 * @return the class probabilities.
	 */
	public double[] predictProbabilities(Instance instance);

}


================================================
FILE: src/main/java/mltk/predictor/Regressor.java
================================================
package mltk.predictor;

import mltk.core.Instance;

/**
 * Interface for regressors.
 * 
 * @author Yin Lou
 * 
 */
public interface Regressor extends Predictor {

	/**
	 * Regresses an instance.
	 * 
	 * @param instance the instance to regress.
	 * @return a regressed value.
	 */
	public double regress(Instance instance);

}


================================================
FILE: src/main/java/mltk/predictor/evaluation/AUC.java
================================================
package mltk.predictor.evaluation;

import java.util.Arrays;
import java.util.Comparator;

import mltk.core.Instances;
import mltk.util.tuple.DoublePair;

/**
 * Class for evaluating area under ROC curve.
 * 
 * @author Yin Lou
 *
 */
public class AUC extends SimpleMetric {

	private class DoublePairComparator implements Comparator<DoublePair> {

		@Override
		public int compare(DoublePair o1, DoublePair o2) {
			int cmp = Double.compare(o1.v1, o2.v1);
			if (cmp == 0) {
				cmp = Double.compare(o1.v2, o2.v2);
			}
			return cmp;
		}

	}

	/**
	 * Constructor.
	 */
	public AUC() {
		super(true);
	}

	@Override
	public double eval(double[] preds, double[] targets) {
		DoublePair[] a = new DoublePair[preds.length];
		for (int i = 0; i < preds.length; i++) {
			a[i] = new DoublePair(preds[i], targets[i]);
		}
		return eval(a);
	}

	@Override
	public double eval(double[] preds, Instances instances) {
		DoublePair[] a = new DoublePair[preds.length];
		for (int i = 0; i < preds.length; i++) {
			a[i] = new DoublePair(preds[i], instances.get(i).getTarget());
		}
		return eval(a);
	}
	
	protected double eval(DoublePair[] a) {
		Arrays.sort(a, new DoublePairComparator());
		double[] fraction = new double[a.length];
		for (int idx = 0; idx < fraction.length;) {
			int begin = idx;
			double pos = 0;
			for (; idx < fraction.length && a[idx].v1 == a[begin].v1; idx++) {
				pos += a[idx].v2;
			}
			double frac = pos / (idx - begin);
			for (int i = begin; i < idx; i++) {
				fraction[i] = frac;
			}
		}

		double tt = 0;
		double tf = 0;
		double ft = 0;
		double ff = 0;

		for (int i = 0; i < a.length; i++) {
			tf += a[i].v2;
			ff += 1 - a[i].v2;
		}

		double area = 0;
		double tpfPrev = 0;
		double fpfPrev = 0;

		for (int i = a.length - 1; i >= 0; i--) {
			tt += fraction[i];
			tf -= fraction[i];
			ft += 1 - fraction[i];
			ff -= 1 - fraction[i];
			double tpf = tt / (tt + tf);
			double fpf = 1.0 - ff / (ft + ff);
			area += 0.5 * (tpf + tpfPrev) * (fpf - fpfPrev);
			tpfPrev = tpf;
			fpfPrev = fpf;
		}

		return area;
	}

}


================================================
FILE: src/main/java/mltk/predictor/evaluation/ConvergenceTester.java
================================================
package mltk.predictor.evaluation;

import java.util.ArrayList;
import java.util.List;

/**
 * Class for testing convergence given a list of metric values.
 * 
 * @author Yin Lou
 *
 */
public class ConvergenceTester {

	protected int minNumPoints;
	protected int n;
	protected double c;
	protected double bestSoFar;
	protected int bestIdx;
	protected Metric metric;
	protected List<Double> measureList;
	
	/**
	 * Parses the convergence criteria string.
	 * 
	 * @param cc the convergence criteria string.
	 * @return a convergence tester.
	 */
	public static ConvergenceTester parse(String cc) {
		int minNumPoints = -1;
		int n = 0;
		double c = 1.0;
		if (cc != null && !cc.equals("")) {
			String[] strs = cc.split(":");
			if (strs.length > 0) {
				minNumPoints = Integer.parseInt(strs[0]);
			}
			if (strs.length > 1) {
				n = Integer.parseInt(strs[1]);
			}
			if (strs.length > 2) {
				c = Double.parseDouble(strs[2]);
			}
		}
		return new ConvergenceTester(minNumPoints, n, c);
	}
	
	/**
	 * Constructor.
	 * 
	 * @param minNumPoints the minimum number of points to be considered convergence.
	 * @param c a constant factor in [0, 1].
	 */
	public ConvergenceTester(int minNumPoints, double c) {
		this(minNumPoints, 0, c, 1000);
	}
	
	/**
	 * Constructor.
	 * 
	 * @param minNumPoints the minimum number of points to be considered convergence.
	 * @param n the n.
	 */
	public ConvergenceTester(int minNumPoints, int n) {
		this(minNumPoints, n, 1.0, 1000);
	}
	
	/**
	 * Constructor.
	 * 
	 * @param minNumPoints the minimum number of points to be considered convergence.
	 * @param n the n.
	 * @param c a constant factor in [0, 1].
	 */
	public ConvergenceTester(int minNumPoints, int n, double c) {
		this(minNumPoints, n, c, 1000);
	}
	
	/**
	 * Constructor. A list of metric values is viewed as converged if the list
	 * has at least {@code minNumPoints} and the {@code getBestIndex() + n < size() * c}.
	 * 
	 * @param minNumPoints the minimum number of points to be considered convergence.
	 * @param n the n.
	 * @param c a constant factor in [0, 1].
	 * @param capacity the initial capacity.
	 */
	public ConvergenceTester(int minNumPoints, int n, double c, int capacity) {
		if (n < 0) {
			throw new IllegalArgumentException("n has to be non-negative.");
		}
		if (!(c >= 0 && c <= 1)) {
			throw new IllegalArgumentException("c should to be in [0, 1].");
		}
		this.minNumPoints = minNumPoints;
		this.n = n;
		this.c = c;
		measureList = new ArrayList<>(capacity);
	}
	
	/**
	 * Returns the metric.
	 * 
	 * @return the metric.
	 */
	public Metric getMetric() {
		return metric;
	}
	
	/**
	 * Sets the metric. This method also resets internal status of this tester.
	 * 
	 * @param metric the metric to set.
	 */
	public void setMetric(Metric metric) {
		this.metric = metric;
		measureList.clear();
		bestSoFar = metric.worstValue();
		bestIdx = -1;
	}
	
	/**
	 * Adds a measure.
	 * 
	 * @param measure the metric value to add.
	 */
	public void add(double measure) {
		measureList.add(measure);
		
		if (metric.isFirstBetter(measure, bestSoFar)) {
			bestSoFar = measure;
			bestIdx = measureList.size() - 1;
		}
	}
	
	/**
	 * Returns the index of best metric value so far.
	 * 
	 * @return the index of best metric value so far.
	 */
	public int getBestIndex() {
		return bestIdx;
	}
	
	/**
	 * Returns the best measure value so far.
	 * 
	 * @return the best measure value so far.
	 */
	public double getBestMetricValue() {
		return bestSoFar;
	}
	
	/**
	 * Returns the number of points.
	 * 
	 * @return the number of points.
	 */
	public int size() {
		return measureList.size();
	}
	
	/**
	 * Returns the list of metric values.
	 * 
	 * @return the list of metric values.
	 */
	public List<Double> getMeasureList() {
		return measureList;
	}
	
	/**
	 * Returns {@code true} if the series is converged.
	 * 
	 * @return {@code true} if the series is converged.
	 */
	public boolean isConverged() {
		return minNumPoints >= 0 && measureList.size() >= minNumPoints
				&& bestIdx > 0 && bestIdx + n < measureList.size() * c;
	}
	
}


================================================
FILE: src/main/java/mltk/predictor/evaluation/Error.java
================================================
package mltk.predictor.evaluation;

import mltk.core.Instances;

/**
 * Class for evaluating error rate.
 * 
 * @author Yin Lou
 *
 */
public class Error extends SimpleMetric {

	/**
	 * Constructor.
	 */
	public Error() {
		super(false);
	}

	@Override
	public double eval(double[] preds, double[] targets) {
		double error = 0;
		for (int i = 0; i < preds.length; i++) {
			// Handles both probability and predicted label
			double cls = preds[i] <= 0 ? 0 : 1;
			if (cls != targets[i]) {
				error++;
			}
		}
		return error / preds.length;
	}

	@Override
	public double eval(double[] preds, Instances instances) {
		double error = 0;
		for (int i = 0; i < preds.length; i++) {
			// Handles both probability and predicted label
			double cls = preds[i] <= 0 ? 0 : 1;
			if (cls != instances.get(i).getTarget()) {
				error++;
			}
		}
		return error / preds.length;
	}

}


================================================
FILE: src/main/java/mltk/predictor/evaluation/Evaluator.java
================================================
package mltk.predictor.evaluation;

import java.util.List;

import mltk.cmdline.Argument;
import mltk.cmdline.CmdLineParser;
import mltk.core.Instance;
import mltk.core.Instances;
import mltk.core.io.InstancesReader;
import mltk.predictor.ProbabilisticClassifier;
import mltk.predictor.Classifier;
import mltk.predictor.Regressor;
import mltk.predictor.io.PredictorReader;
import mltk.util.OptimUtils;

/**
 * Class for making evaluations.
 * 
 * @author Yin Lou
 * 
 */
public class Evaluator {

	/**
	 * Returns the area under ROC curve.
	 * 
	 * @param classifier a classifier that outputs probability.
	 * @param instances the instances.
	 * @return the area under ROC curve.
	 */
	public static double evalAreaUnderROC(ProbabilisticClassifier classifier, Instances instances) {
		double[] probs = new double[instances.size()];
		double[] targets = new double[instances.size()];
		for (int i = 0; i < probs.length; i++) {
			Instance instance = instances.get(i);
			probs[i] = classifier.predictProbabilities(instance)[1];
			targets[i] = instance.getTarget();
		}
		return new AUC().eval(probs, targets);
	}

	/**
	 * Returns the root mean squared error.
	 * 
	 * @param preds the predictions.
	 * @param targets the targets.
	 * @return the root mean squared error.
	 */
	public static double evalRMSE(List<Double> preds, List<Double> targets) {
		double rmse = 0;
		for (int i = 0; i < preds.size(); i++) {
			double d = targets.get(i) - preds.get(i);
			rmse += d * d;
		}
		rmse = Math.sqrt(rmse / preds.size());
		return rmse;
	}

	/**
	 * Returns the root mean squared error.
	 * 
	 * @param regressor the regressor.
	 * @param instances the instances.
	 * @return the root mean squared error.
	 */
	public static double evalRMSE(Regressor regressor, Instances instances) {
		double rmse = 0;
		for (int i = 0; i < instances.size(); i++) {
			Instance instance = instances.get(i);
			double target = instance.getTarget();
			double pred = regressor.regress(instance);
			double d = target - pred;
			rmse += d * d;
		}
		rmse = Math.sqrt(rmse / instances.size());
		return rmse;
	}

	/**
	 * Returns the classification error.
	 * 
	 * @param classifier the classifier.
	 * @param instances the instances.
	 * @return the classification error.
	 */
	public static double evalError(Classifier classifier, Instances instances) {
		double error = 0;
		for (int i = 0; i < instances.size(); i++) {
			Instance instance = instances.get(i);
			double target = instance.getTarget();
			double pred = classifier.classify(instance);
			if (target != pred) {
				error++;
			}
		}
		error /= instances.size();
		return error;
	}
	
	/**
	 * Returns the logistic loss.
	 * 
	 * @param regressor the regressor.
	 * @param instances the instances.
	 * @return the logistic loss.
	 */
	public static double evalLogisticLoss(Regressor regressor, Instances instances) {
		double loss = 0;
		for (int i = 0; i < instances.size(); i++) {
			Instance instance = instances.get(i);
			double pred = regressor.regress(instance);
			loss += OptimUtils.computeLogisticLoss(pred, instance.getTarget());
		}
		loss /= instances.size();
		return loss;
	}
	
	/**
	 * Returns the mean absolute error.
	 * 
	 * @param regressor the regressor.
	 * @param instances the instances.
	 * @return the mean absolute error.
	 */
	public static double evalMAE(Regressor regressor, Instances instances) {
		double mae = 0;
		for (int i = 0; i < instances.size(); i++) {
			Instance instance = instances.get(i);
			double target = instance.getTarget();
			double pred = regressor.regress(instance);
			double d = target - pred;
			mae += Math.abs(d);
		}
		mae /= instances.size();
		return mae;
	}

	static class Options {

		@Argument(name = "-r", description = "attribute file path")
		String attPath = null;

		@Argument(name = "-d", description = "data set path", required = true)
		String dataPath = null;

		@Argument(name = "-m", description = "model path", required = true)
		String modelPath = null;

		@Argument(name = "-e", description = "AUC (a), Error (c), Logistic Loss (l), MAE(m), RMSE (r) (default: r)")
		String task = "r";

	}

	/**
	 * Evaluates a predictor.
	 * 
	 * <pre>
	 * Usage: mltk.predictor.evaluation.Evaluator
	 * -d	data set path
	 * -m	model path
	 * [-r]	attribute file path
	 * [-e]	AUC (a), Error (c), Logistic Loss (l), MAE(m), RMSE (r) (default: r)
	 * </pre>
	 * 
	 * @param args the command line arguments.
	 * @throws Exception
	 */
	public static void main(String[] args) throws Exception {
		Options opts = new Options();
		CmdLineParser parser = new CmdLineParser(Evaluator.class, opts);
		try {
			parser.parse(args);
		} catch (IllegalArgumentException e) {
			parser.printUsage();
			System.exit(1);
		}

		Instances instances = InstancesReader.read(opts.attPath, opts.dataPath);
		mltk.predictor.Predictor predictor = PredictorReader.read(opts.modelPath);

		switch (opts.task) {
			case "a":
				double auc = evalAreaUnderROC((ProbabilisticClassifier) predictor, instances);
				System.out.println("AUC: " + auc);
				break;
			case "c":
				double error = evalError((Classifier) predictor, instances);
				System.out.println("Error: " + error);
				break;
			case "l":
				double logisticLoss = evalLogisticLoss((Regressor) predictor, instances);
				System.out.println("Logistic Loss: " + logisticLoss);
				break;
			case "m":
				double mae = evalMAE((Regressor) predictor, instances);
				System.out.println("MAE: " + mae);
				break;
			case "r":
				double rmse = evalRMSE((Regressor) predictor, instances);
				System.out.println("RMSE: " + rmse);
				break;
			default:
				break;
		}
	}

}


================================================
FILE: src/main/java/mltk/predictor/evaluation/LogLoss.java
================================================
package mltk.predictor.evaluation;

import mltk.core.Instances;
import mltk.util.OptimUtils;

/**
 * Class for evaluating log loss (cross entropy).
 * 
 * @author Yin Lou
 *
 */
public class LogLoss extends SimpleMetric {
	
	protected boolean isRawScore;

	/**
	 * Constructor.
	 */
	public LogLoss() {
		this(false);
	}
	
	/**
	 * Constructor.
	 * 
	 * @param isRawScore {@code true} if raw score is expected as input.
	 */
	public LogLoss(boolean isRawScore) {
		super(false);
		this.isRawScore = isRawScore;
	}

	@Override
	public double eval(double[] preds, double[] targets) {
		return OptimUtils.computeLogLoss(preds, targets, isRawScore);
	}

	@Override
	public double eval(double[] preds, Instances instances) {
		double logLoss = 0;
		for (int i = 0; i < preds.length; i++) {
			logLoss += OptimUtils.computeLogLoss(preds[i], instances.get(i).getTarget(), isRawScore);
		}
		logLoss /= preds.length;
		return logLoss;
	}
	
	/**
	 * Returns {@code true} if raw score is expected as input.
	 * 
	 * @return {@code true} if raw score is expected as input.
	 */
	public boolean isRawScore() {
		return isRawScore;
	}

}


================================================
FILE: src/main/java/mltk/predictor/evaluation/LogisticLoss.java
================================================
package mltk.predictor.evaluation;

import mltk.core.Instances;
import mltk.util.OptimUtils;

/**
 * Class for evaluating logistic loss.
 * 
 * @author Yin Lou
 *
 */
public class LogisticLoss extends SimpleMetric {

	/**
	 * Constructor.
	 */
	public LogisticLoss() {
		super(false);
	}

	@Override
	public double eval(double[] preds, double[] targets) {
		return OptimUtils.computeLogisticLoss(preds, targets);
	}

	@Override
	public double eval(double[] preds, Instances instances) {
		double logisticLoss = 0;
		for (int i = 0; i < preds.length; i++) {
			logisticLoss += OptimUtils.computeLogisticLoss(preds[i], instances.get(i).getTarget());
		}
		logisticLoss /= preds.length;
		return logisticLoss;
	}

}


================================================
FILE: src/main/java/mltk/predictor/evaluation/MAE.java
================================================
package mltk.predictor.evaluation;

import mltk.core.Instances;

/**
 * Class for evaluating mean absolute error (MAE).
 * 
 * @author Yin Lou
 *
 */
public class MAE extends SimpleMetric {

	/**
	 * Constructor.
	 */
	public MAE() {
		super(false);
	}

	@Override
	public double eval(double[] preds, double[] targets) {
		double mae = 0;
		for (int i = 0; i < preds.length; i++) {
			mae += Math.abs(targets[i] - preds[i]);
		}
		mae /= preds.length;
		return mae;
	}

	@Override
	public double eval(double[] preds, Instances instances) {
		double mae = 0;
		for (int i = 0; i < preds.length; i++) {
			mae += Math.abs(instances.get(i).getTarget() - preds[i]);
		}
		mae /= preds.length;
		return mae;
	}

}


================================================
FILE: src/main/java/mltk/predictor/evaluation/Metric.java
================================================
package mltk.predictor.evaluation;

import java.util.List;

import mltk.core.Instances;
import mltk.util.MathUtils;

/**
 * Class for evaluation metrics.
 * 
 * @author Yin Lou
 *
 */
public abstract class Metric {

	private boolean isLargerBetter;

	/**
	 * Constructor.
	 * 
	 * @param isLargerBetter {@code true} if larger value is better.
	 */
	public Metric(boolean isLargerBetter) {
		this.isLargerBetter = isLargerBetter;
	}
	
	/**
	 * Returns {@code true} if larger value is better for this metric.
	 * 
	 * @return {@code true} if larger value is better for this metric.
	 */
	public boolean isLargerBetter() {
		return isLargerBetter;
	}

	/**
	 * Returns {@code true} if the first value is better.
	 * 
	 * @param a the 1st value.
	 * @param b the 2nd value.
	 * @return {@code true} if the first value is better.
	 */
	public boolean isFirstBetter(double a, double b) {
		return MathUtils.isFirstBetter(a, b, isLargerBetter);
	}
	
	/**
	 * Returns the worst value of this metric.
	 * 
	 * @return the worst value of this metric.
	 */
	public double worstValue() {
		if (isLargerBetter) {
			return Double.NEGATIVE_INFINITY;
		} else {
			return Double.POSITIVE_INFINITY;
		}
	}
	
	/**
	 * Evaluates predictions on a dataset.
	 * 
	 * @param preds the predictions.
	 * @param instances the dataset.
	 * @return the evaluation measure.
	 */
	public abstract double eval(double[] preds, Instances instances);
	
	/**
	 * Returns the index of best metric value in a list.
	 * 
	 * @param list the list of metric values.
	 * @return the index of best metric value in a list.
	 */
	public int searchBestMetricValueIndex(List<Double> list) {
		double bestSoFar = worstValue();
		int idx = -1;
		for (int i = 0; i < list.size(); i++) {
			if (isFirstBetter(list.get(i), bestSoFar)) {
				bestSoFar = list.get(i);
				idx = i;
			}
		}
		return idx;
	}

}


================================================
FILE: src/main/java/mltk/predictor/evaluation/MetricFactory.java
================================================
package mltk.predictor.evaluation;

import java.util.HashMap;
import java.util.Map;

/**
 * Factory class for creating metrics.
 *  
 * @author Yin Lou
 *
 */
public class MetricFactory {
	
	private static Map<String, Metric> map;
	
	static {
		map = new HashMap<>();
		map.put("auc", new AUC());
		map.put("error", new Error());
		map.put("logisticloss", new LogisticLoss());
		map.put("logloss", new LogLoss(false));
		map.put("logloss_t", new LogLoss(true));
		map.put("mae", new MAE());
		map.put("rmse", new RMSE());
	}

	/**
	 * Returns the metric.
	 * 
	 * @param str the metric string.
	 * @return the metric.
	 */
	public static Metric getMetric(String str) {
		String[] data = str.toLowerCase().split(":");
		String name = data[0];
		if (data.length == 1) {
			if (!map.containsKey(name)) {
				throw new IllegalArgumentException("Unrecognized metric name: " + name);
			} else {
				return map.get(name);
			}
		} else {
			if (name.equals("logloss")) {
				if (data[1].startsWith("t")) {
					return map.get("logloss_t");
				} else {
					return map.get(name);
				}
			} else if (map.containsKey(name)) {
				return map.get(name);
			}
		}
		return null;
	}
	
}


================================================
FILE: src/main/java/mltk/predictor/evaluation/Predictor.java
================================================
package mltk.predictor.evaluation;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;

import mltk.cmdline.Argument;
import mltk.cmdline.CmdLineParser;
import mltk.core.Instance;
import mltk.core.Instances;
import mltk.core.io.InstancesReader;
import mltk.predictor.Classifier;
import mltk.predictor.Learner.Task;
import mltk.predictor.ProbabilisticClassifier;
import mltk.predictor.Regressor;
import mltk.predictor.io.PredictorReader;
import mltk.util.OptimUtils;

/**
 * Class for making predictions.
 * 
 * @author Yin Lou
 * 
 */
public class Predictor {
	
	static class Options {

		@Argument(name = "-r", description = "attribute file path")
		String attPath = null;

		@Argument(name = "-d", description = "data set path", required = true)
		String dataPath = null;

		@Argument(name = "-m", description = "model path", required = true)
		String modelPath = null;

		@Argument(name = "-p", description = "prediction path")
		String predictionPath = null;

		@Argument(name = "-R", description = "residual path")
		String residualPath = null;

		@Argument(name = "-g", description = "task between classification (c) and regression (r) (default: r)")
		String task = "r";

		@Argument(name = "-P", description = "output probablity (default: false)")
		boolean prob = false;

	}

	/**
	 * Makes predictions on a dataset.
	 * 
	 * <pre>
	 * Usage: mltk.predictor.evaluation.Predictor
	 * -d	data set path
	 * -m	model path
	 * [-r]	attribute file path
	 * [-p]	prediction path
	 * [-R]	residual path
	 * [-g]	task between classification (c) and regression (r) (default: r)
	 * [-P]	output probability (default: false)
	 * </pre>
	 * 
	 * @param args the command line arguments.
	 * @throws Exception
	 */
	public static void main(String[] args) throws Exception {
		Options opts = new Options();
		CmdLineParser parser = new CmdLineParser(Predictor.class, opts);
		Task task = null;
		try {
			parser.parse(args);
			task = Task.get(opts.task);
		} catch (IllegalArgumentException e) {
			parser.printUsage();
			System.exit(1);
		}

		Instances instances = InstancesReader.read(opts.attPath, opts.dataPath);
		mltk.predictor.Predictor predictor = PredictorReader.read(opts.modelPath);

		switch (task) {
			case REGRESSION:
				Regressor regressor = (Regressor) predictor;
				double rmse = Evaluator.evalRMSE(regressor, instances);
				System.out.println("RMSE on Test: " + rmse);

				if (opts.predictionPath != null) {
					PrintWriter out = new PrintWriter(opts.predictionPath);
					for (Instance instance : instances) {
						double pred = regressor.regress(instance);
						out.println(pred);
					}
					out.flush();
					out.close();
				}

				if (opts.residualPath != null) {
					PrintWriter out = new PrintWriter(opts.residualPath);
					for (Instance instance : instances) {
						double pred = regressor.regress(instance);
						out.println(instance.getTarget() - pred);
					}
					out.flush();
					out.close();
				}

				break;
			case CLASSIFICATION:
				Classifier classifier = (Classifier) predictor;
				double error = Evaluator.evalError(classifier, instances);
				System.out.println("Error rate on Test: " + (error * 100) + " %");

				if (opts.predictionPath != null) {
					if (opts.prob) {
						PrintWriter out = new PrintWriter(opts.predictionPath);
						ProbabilisticClassifier probClassifier = (ProbabilisticClassifier) predictor;
						for (Instance instance : instances) {
							double[] pred = probClassifier.predictProbabilities(instance);
							out.println(Arrays.toString(pred));
						}
						out.flush();
						out.close();
					} else {
						PrintWriter out = new PrintWriter(opts.predictionPath);
						for (Instance instance : instances) {
							double pred = classifier.classify(instance);
							out.println((int) pred);
						}
						out.flush();
						out.close();
					}
				}

				if (opts.residualPath != null) {
					if (predictor instanceof Regressor) {
						PrintWriter out = new PrintWriter(opts.residualPath);
						Regressor regressingClassifier = (Regressor) predictor;
						for (Instance instance : instances) {
							double pred = regressingClassifier.regress(instance);
							int cls = (int) instance.getTarget();
							out.println(OptimUtils.getPseudoResidual(pred, cls));
						}
						out.flush();
						out.close();
					} else {
						System.out.println("Warning: Classifier does not support outputing pseudo residual.");
					}
				}

				break;
			default:
				break;
		}
	}

	/**
	 * Makes predictions for a dataset.
	 * 
	 * @param regressor the model.
	 * @param instances the dataset.
	 * @param path the output path.
	 * @param residual {@code true} if residuals are the output.
	 * @throws IOException
	 */
	public static void predict(Regressor regressor, Instances instances, String path, boolean residual)
			throws IOException {
		PrintWriter out = new PrintWriter(path);
		if (residual) {
			for (Instance instance : instances) {
				double pred = regressor.regress(instance);
				out.println(instance.getTarget() - pred);
			}
		} else {
			for (Instance instance : instances) {
				double pred = regressor.regress(instance);
				out.println(pred);
			}
		}
		out.flush();
		out.close();
	}

	/**
	 * Makes predictions for a dataset.
	 * 
	 * @param classifier the model.
	 * @param instances the dataset.
	 * @param path the output path.
	 * @throws IOException
	 */
	public static void predict(Classifier classifier, Instances instances, String path) throws IOException {
		PrintWriter out = new PrintWriter(path);
		for (Instance instance : instances) {
			int pred = classifier.classify(instance);
			out.println(pred);
		}
		out.flush();
		out.close();
	}

}


================================================
FILE: src/main/java/mltk/predictor/evaluation/RMSE.java
================================================
package mltk.predictor.evaluation;

import mltk.core.Instances;

/**
 * Class for evaluating root mean squared error (RMSE).
 * 
 * @author Yin Lou
 *
 */
public class RMSE extends SimpleMetric {

	/**
	 * Constructor.
	 */
	public RMSE() {
		super(false);
	}

	@Override
	public double eval(double[] preds, double[] targets) {
		double rmse = 0;
		for (int i = 0; i < preds.length; i++) {
			double d = targets[i] - preds[i];
			rmse += d * d;
		}
		rmse = Math.sqrt(rmse / preds.length);
		return rmse;
	}

	@Override
	public double eval(double[] preds, Instances instances) {
		double rmse = 0;
		for (int i = 0; i < preds.length; i++) {
			double d = instances.get(i).getTarget() - preds[i];
			rmse += d * d;
		}
		rmse = Math.sqrt(rmse / preds.length);
		return rmse;
	}

}


================================================
FILE: src/main/java/mltk/predictor/evaluation/SimpleMetric.java
================================================
package mltk.predictor.evaluation;

/**
 * Class for simple metrics.
 * 
 * @author Yin Lou
 *
 */
public abstract class SimpleMetric extends Metric {

	/**
	 * Constructor.
	 * 
	 * @param isLargerBetter {@code true} if larger value is better.
	 */
	public SimpleMetric(boolean isLargerBetter) {
		super(isLargerBetter);
	}
	
	/**
	 * Evaluates predictions given targets.
	 * 
	 * @param preds the predictions.
	 * @param targets the targets.
	 * @return the evaluation measure.
	 */
	public abstract double eval(double[] preds, double[] targets);

}


================================================
FILE: src/main/java/mltk/predictor/evaluation/package-info.java
================================================
/**
 * Provides classes for evaluating predictors.
 */
package mltk.predictor.evaluation;

================================================
FILE: src/main/java/mltk/predictor/function/Array1D.java
================================================
package mltk.predictor.function;

import java.io.BufferedReader;
import java.io.PrintWriter;
import java.util.Arrays;

import mltk.core.Instance;
import mltk.predictor.Regressor;
import mltk.util.ArrayUtils;

/**
 * Class for 1D lookup tables.
 * 
 * @author Yin Lou
 * 
 */
public class Array1D implements Regressor, UnivariateFunction {

	/**
	 * Attribute index. Must be binned/nominal attribute; otherwise the behavior is not guaranteed.
	 */
	protected int attIndex;

	/**
	 * Predictions.
	 */
	protected double[] predictions;
	
	/**
	 * Prediction on missing value.
	 */
	protected double predictionOnMV;

	/**
	 * Constructor.
	 */
	public Array1D() {

	}
	
	/**
	 * Constructs a 1D lookup table.
	 * 
	 * @param attIndex the attribute index. The attribute must be discretized or nominal.
	 * @param predictions the prediction array.
	 */
	public Array1D(int attIndex, double[] predictions) {
		this(attIndex, predictions, 0.0);
	}

	/**
	 * Constructs a 1D lookup table.
	 * 
	 * @param attIndex the attribute index. The attribute must be discretized or nominal.
	 * @param predictions the prediction array.
	 * @param predictionOnMV the prediction on missing value.
	 */
	public Array1D(int attIndex, double[] predictions, double predictionOnMV) {
		this.attIndex = attIndex;
		this.predictions = predictions;
		this.predictionOnMV = predictionOnMV;
	}

	/**
	 * Returns the attribute index.
	 * 
	 * @return the attribute index.
	 */
	public int getAttributeIndex() {
		return attIndex;
	}

	/**
	 * Sets the attribute index.
	 * 
	 * @param attIndex the new attribute index.
	 */
	public void setAttributeIndex(int attIndex) {
		this.attIndex = attIndex;
	}

	/**
	 * Returns the internal prediction array.
	 * 
	 * @return the internal prediction array.
	 */
	public double[] getPredictions() {
		return predictions;
	}

	/**
	 * Sets the internal prediction array.
	 * 
	 * @param predictions the new prediction array.
	 */
	public void setPredictions(double[] predictions) {
		this.predictions = predictions;
	}
	
	/**
	 * Returns the prediction on missing value.
	 * 
	 * @return the prediction on missing value.
	 */
	public double getPredictionOnMV() {
		return predictionOnMV;
	}
	
	/**
	 * Sets prediction on missing value.
	 * 
	 * @param predictionOnMV the prediction on missing value.
	 */
	public void setPredictionOnMV(double predictionOnMV) {
		this.predictionOnMV = predictionOnMV;
	}

	@Override
	public void read(BufferedReader in) throws Exception {
		String line = in.readLine();
		String[] data = line.split(": ");
		attIndex = Integer.parseInt(data[1]);
		
		line = in.readLine();
		data = line.split(": ");
		predictionOnMV = Double.parseDouble(data[1]);

		in.readLine();
		predictions = ArrayUtils.parseDoubleArray(in.readLine());
	}

	@Override
	public void write(PrintWriter out) throws Exception {
		out.printf("[Predictor: %s]\n", this.getClass().getCanonicalName());
		out.println("AttIndex: " + attIndex);
		out.println("PredictionOnMV: " + predictionOnMV);
		out.println("Predictions: " + predictions.length);
		out.println(Arrays.toString(predictions));
	}

	@Override
	public double regress(Instance instance) {
		double v = instance.getValue(attIndex);
		if (!Double.isNaN(v)) {
			return predictions[(int) v];
		} else {
			return predictionOnMV;
		}
	}

	/**
	 * Adds this lookup table with another one.
	 * 
	 * @param ary the other lookup table.
	 * @return this lookup table.
	 */
	public Array1D add(Array1D ary) {
		if (attIndex != ary.attIndex) {
			throw new IllegalArgumentException("Cannot add arrays on different terms");
		}
		for (int i = 0; i < predictions.length; i++) {
			predictions[i] += ary.predictions[i];
		}
		predictionOnMV += ary.predictionOnMV;
		return this;
	}

	@Override
	public double evaluate(double x) {
		if (!Double.isNaN(x)) {
			return predictions[(int) x];
		} else {
			return predictionOnMV;
		}
	}

	@Override
	public Array1D copy() {
		double[] predictionsCopy = Arrays.copyOf(predictions, predictions.length);
		return new Array1D(attIndex, predictionsCopy, predictionOnMV);
	}

}


================================================
FILE: src/main/java/mltk/predictor/function/Array2D.java
================================================
package mltk.predictor.function;

import java.io.BufferedReader;
import java.io.PrintWriter;
import java.util.Arrays;

import mltk.core.Instance;
import mltk.predictor.Regressor;
import mltk.util.ArrayUtils;
import mltk.util.tuple.IntPair;

/**
 * Class for 2D lookup tables.
 * 
 * @author Yin Lou
 * 
 */
public class Array2D implements Regressor, BivariateFunction {

	/**
	 * First attribute index.
	 */
	protected int attIndex1;

	/**
	 * Second attribute index.
	 */
	protected int attIndex2;

	/**
	 * Predictions.
	 */
	protected double[][] predictions;
	
	/**
	 * Predictions on missing value for attribute 1.
	 */
	protected double[] predictionsOnMV1;
	
	/**
	 * Predictions on missing value for attribute 2.
	 */
	protected double[] predictionsOnMV2;
	
	/**
	 * Prediction when both attribute 1 and 2 are missing.
	 */
	protected double predictionOnMV12;

	/**
	 * Constructor.
	 */
	public Array2D() {

	}

	/**
	 * Constructs a 2D lookup table.
	 * 
	 * @param attIndex1 the 1st attribute index. The attribute must be discretized or nominal.
	 * @param attIndex2 the 2nd attribute index. The attribute must be discretized or nominal.
	 * @param predictions the prediction matrix.
	 */
	public Array2D(int attIndex1, int attIndex2, double[][] predictions) {
		this.attIndex1 = attIndex1;
		this.attIndex2 = attIndex2;
		this.predictions = predictions;
	}
	
	/**
	 * Constructs a 2D lookup table.
	 * 
	 * @param attIndex1 the 1st attribute index. The attribute must be discretized or nominal.
	 * @param attIndex2 the 2nd attribute index. The attribute must be discretized or nominal.
	 * @param predictions the prediction matrix.
	 * @param predictionsOnMV1 the prediction array when the 1st attribute is missing.
	 * @param predictionsOnMV2 the prediction array when the 2nd attribute is missing.
	 * @param predictionOnMV12 the prediction when both attributes are missing.
	 */
	public Array2D(int attIndex1, int attIndex2, double[][] predictions,
			double[] predictionsOnMV1, double[] predictionsOnMV2, double predictionOnMV12) {
		this.attIndex1 = attIndex1;
		this.attIndex2 = attIndex2;
		this.predictions = predictions;
		this.predictionsOnMV1 = predictionsOnMV1;
		this.predictionsOnMV2 = predictionsOnMV2;
		this.predictionOnMV12 = predictionOnMV12;
	}

	/**
	 * Returns the index of 1st attribute.
	 * 
	 * @return the index of 1st attribute.
	 */
	public int getAttributeIndex1() {
		return attIndex1;
	}

	/**
	 * Returns the index of 2nd attribute.
	 * 
	 * @return the index of 2nd attribute.
	 */
	public int getAttributeIndex2() {
		return attIndex2;
	}

	/**
	 * Returns the attribute indices pair.
	 * 
	 * @return the attribute indices pair.
	 */
	public IntPair getAttributeIndices() {
		return new IntPair(attIndex1, attIndex2);
	}

	/**
	 * Sets the attribute indices.
	 * 
	 * @param attIndex1 the new 1st attribute index.
	 * @param attIndex2 the new 2nd attribute index.
	 */
	public void setAttributeIndices(int attIndex1, int attIndex2) {
		this.attIndex1 = attIndex1;
		this.attIndex2 = attIndex2;
	}

	/**
	 * Returns the internal prediction matrix.
	 * 
	 * @return the internal prediction matrix.
	 */
	public double[][] getPredictions() {
		return predictions;
	}

	/**
	 * Sets the internal prediction matrix.
	 * 
	 * @param predictions the new prediction matrix.
	 */
	public void setPredictions(double[][] predictions) {
		this.predictions = predictions;
	}
	
	/**
	 * Returns the internal prediction array when the 1st attribute is missing.
	 * 
	 * @return the internal prediction array when the 1st attribute is missing.
	 */
	public double[] getPredictionsOnMV1() {
		return predictionsOnMV1;
	}
	
	/**
	 * Sets the internal prediction array when the 1st attribute is missing.
	 * 
	 * @param predictionsOnMV1 the new prediction array.
	 */
	public void setPredictionsOnMV1(double[] predictionsOnMV1) {
		this.predictionsOnMV1 = predictionsOnMV1;
	}
	
	/**
	 * Returns the internal prediction array when the 2nd attribute is missing.
	 * 
	 * @return the internal prediction array when the 2nd attribute is missing.
	 */
	public double[] getPredictionsOnMV2() {
		return predictionsOnMV2;
	}
	
	/**
	 * Sets the internal prediction array when the 2nd attribute is missing.
	 * 
	 * @param predictionsOnMV2 the new prediction array.
	 */
	public void setPredictionsOnMV2(double[] predictionsOnMV2) {
		this.predictionsOnMV2 = predictionsOnMV2;
	}
	
	/**
	 * Returns the prediction when both attributes are missing.
	 * 
	 * @return the prediction when both attributes are missing.
	 */
	public double getPredictionOnMV12() {
		return predictionOnMV12;
	}
	
	/**
	 * Sets the prediction when both attributes are missing.
	 * 
	 * @param predictionOnMV12 the new prediction.
	 */
	public void setPredictionOnMV12(double predictionOnMV12) {
		this.predictionOnMV12 = predictionOnMV12;
	}

	@Override
	public void read(BufferedReader in) throws Exception {
		String line = in.readLine();
		String[] data = line.split(": ");
		attIndex1 = Integer.parseInt(data[1]);
		line = in.readLine();
		data = line.split(": ");
		attIndex2 = Integer.parseInt(data[1]);

		String[] dim = in.readLine().split(": ")[1].split("x");
		predictions = new double[Integer.parseInt(dim[0])][];
		for (int i = 0; i < predictions.length; i++) {
			predictions[i] = ArrayUtils.parseDoubleArray(in.readLine());
		}
		
		in.readLine();
		predictionsOnMV1 = ArrayUtils.parseDoubleArray(in.readLine());
		
		in.readLine();
		predictionsOnMV2 = ArrayUtils.parseDoubleArray(in.readLine());
		
		data = in.readLine().split(": ");
		predictionOnMV12 = Double.parseDouble(data[1]);
	}

	@Override
	public void write(PrintWriter out) throws Exception {
		out.printf("[Predictor: %s]\n", this.getClass().getCanonicalName());
		out.println("AttIndex1: " + attIndex1);
		out.println("AttIndex2: " + attIndex2);
		out.println("Predictions: " + predictions.length + "x" + predictions[0].length);
		for (int i = 0; i < predictions.length; i++) {
			out.println(Arrays.toString(predictions[i]));
		}
		out.println("PredictionsOnMV1: " + predictionsOnMV1.length);
		out.println(Arrays.toString(predictionsOnMV1));
		out.println("PredictionsOnMV2: " + predictionsOnMV2.length);
		out.println(Arrays.toString(predictionsOnMV2));
		out.println("PredictionOnMV12: " + predictionOnMV12);
	}

	@Override
	public double regress(Instance instance) {
		return evaluate(instance.getValue(attIndex1), instance.getValue(attIndex2));
	}

	/**
	 * Adds this lookup table with another one.
	 * 
	 * @param ary the other lookup table.
	 * @return this lookup table.
	 */
	public Array2D add(Array2D ary) {
		if (attIndex1 != ary.attIndex1 || attIndex2 != ary.attIndex2) {
			throw new IllegalArgumentException("Cannot add arrays on differnt terms");
		}
		for (int i = 0; i < predictions.length; i++) {
			predictionsOnMV2[i] += ary.predictionsOnMV2[i];
			
			double[] preds1 = predictions[i];
			double[] preds2 = ary.predictions[i];
			for (int j = 0; j < preds1.length; j++) {
				predictionsOnMV1[j] += ary.predictionsOnMV1[j];
				
				preds1[j] += preds2[j];
			}
		}
		predictionOnMV12 += ary.predictionOnMV12;
		return this;
	}

	@Override
	public double evaluate(double x, double y) {
		if (!Double.isNaN(x) && !Double.isNaN(y)) {
			return predictions[(int) x][(int) y];
		} else if (Double.isNaN(x) && !Double.isNaN(y)) {
			return predictionsOnMV1[(int) y];
		} else if (!Double.isNaN(x) && Double.isNaN(y)) {
			return predictionsOnMV2[(int) x];
		} else {
			return predictionOnMV12;
		}
		
	}

	@Override
	public Array2D copy() {
		double[][] predictionsCopy = new double[predictions.length][];
		for (int i = 0; i < predictionsCopy.length; i++) {
			predictionsCopy[i] = Arrays.copyOf(predictions[i], predictions[i].length);
		}
		double[] predictionsOnMV1Copy = Arrays.copyOf(predictionsOnMV1, predictionsOnMV1.length);
		double[] predictionsOnMV2Copy = Arrays.copyOf(predictionsOnMV2, predictionsOnMV2.length);
		return new Array2D(attIndex1, attIndex2, predictionsCopy,
				predictionsOnMV1Copy, predictionsOnMV2Copy, predictionOnMV12);
	}

}


================================================
FILE: src/main/java/mltk/predictor/function/BaggedLineCutter.java
================================================
package mltk.predictor.function;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import mltk.core.Attribute;
import mltk.core.BinnedAttribute;
import mltk.core.Instance;
import mltk.core.Instances;
import mltk.core.NominalAttribute;
import mltk.core.Sampling;
import mltk.predictor.BaggedEnsemble;
import mltk.util.tuple.IntPair;
import mltk.util.Element;
import mltk.util.MathUtils;

/**
 * Class for cutting lines with bagging.
 * 
 * @author Yin Lou
 *
 */
public class BaggedLineCutter extends EnsembledLineCutter {
	
	private List<IntPair[]> samples;
	
	/**
	 * Constructor.
	 */
	public BaggedLineCutter() {
		this(false);
	}
	
	/**
	 * Constructor.
	 * 
	 * @param isClassification {@code true} if it is a classification problem.
	 */
	public BaggedLineCutter(boolean isClassification) {
		attIndex = -1;
		this.isClassification = isClassification;
	}
	
	/**
	 * Creates internal bootstrap samples.
	 * 
	 * @param n the size of the dataset to sample.
	 * @param baggingIters the number of bagging iterations.
	 */
	public void createBags(int n, int baggingIters) {
		samples = new ArrayList<>(baggingIters);
		if (baggingIters <= 0) {
			// No bagging
			IntPair[] indices = new IntPair[n];
			for (int i = 0; i < n; i++) {
				indices[i] = new IntPair(i, 1);
			}
			samples.add(indices);
		} else {
			for (int b = 0; b < baggingIters; b++) {
				samples.add(Sampling.createBootstrapSampleIndices(n));
			}
		}
	}

	@Override
	public BaggedEnsemble build(Instances instances) {
		return build(instances, attIndex, numIntervals);
	}

	@Override
	public BaggedEnsemble build(Instances instances, Attribute attribute, int numIntervals) {
		int attIndex = attribute.getIndex();
		
		if (samples == null) {
			createBags(instances.size(), baggingIters);
		}
		
		BaggedEnsemble ensemble = new BaggedEnsemble(samples.size());
		
		double[] targets = new double[instances.size()];
		double[] fvalues = new double[instances.size()];
		double[] weights = new double[instances.size()];
		for (int i = 0; i < instances.size(); i++) {
			Instance instance = instances.get(i);
			targets[i] = instance.getTarget();
			fvalues[i] = instance.getValue(attribute);
			weights[i] = instance.getWeight();
		}
		
		if (attribute.getType() == Attribute.Type.NUMERIC) {
			for (IntPair[] indices : samples) {
				double sumRespOnMV = 0.0;
				double sumWeightOnMV = 0.0;
				
				List<Element<double[]>> pairs = new ArrayList<>(instances.size());
				for (IntPair entry : indices) {
					int index = entry.v1;
					int w = entry.v2;
					double weight = weights[index];
					double value = fvalues[index];
					double target = targets[index];
					if (!Double.isNaN(value)) {
						if (isClassification) {
							pairs.add(new Element<double[]>(new double[] { target * w, weight * w }, value));
						} else {
							pairs.add(new Element<double[]>(new double[] { target * weight * w, weight * w }, value));
						}
					} else {
						if (isClassification) {
							sumRespOnMV += target * w;
						} else {
							sumRespOnMV += target * weight * w;
						}
						sumWeightOnMV += weight * w;
					}
				}
				
				Collections.sort(pairs);
				List<double[]> histograms = new ArrayList<>();
				LineCutter.getHistograms(pairs, histograms);
				histograms.add(new double[] { Double.NaN, sumRespOnMV, sumWeightOnMV });
				
				Function1D func = LineCutter.build(attIndex, histograms, numIntervals);
				ensemble.add(func);
			}
		} else {
			int size = 0;
			if (attribute.getType() == Attribute.Type.BINNED) {
				size = ((BinnedAttribute) attribute).getNumBins();
			} else {
				size = ((NominalAttribute) attribute).getCardinality();
			}
			for (IntPair[] indices : samples) {
				List<double[]> histograms;
				double sumRespOnMV = 0.0;
				double sumWeightOnMV = 0.0;
				
				double[][] histogram = new double[size][3];
				for (IntPair entry : indices) {
					int index = entry.v1;
					int w = entry.v2;
					double weight = weights[index];
					double value = fvalues[index];
					double target = targets[index];
					
					if (!Double.isNaN(value)) {
						int idx = (int) value;
						if (isClassification) {
							histogram[idx][0] += target * w;
						} else {
							histogram[idx][0] += target * weight * w;
						}
						histogram[idx][1] += weight * w;
					} else {
						if (isClassification) {
							sumRespOnMV += target * w;
						} else {
							sumRespOnMV += target * weight * w;
						}
						sumWeightOnMV += weight * w;
					}
				}

				histograms = new ArrayList<>(histogram.length + 1);
				for (int i = 0; i < histogram.length; i++) {
					if (!MathUtils.isZero(histogram[i][1])) {
						double[] hist = histogram[i];
						histograms.add(new double[] {i, hist[0], hist[1]});
					}
				}
				histograms.add(new double[] { Double.NaN, sumRespOnMV, sumWeightOnMV });
				
				Function1D func = LineCutter.build(attIndex, histograms, numIntervals);
				ensemble.add(func);
			}
		}
		
		return ensemble;
	}

}


================================================
FILE: src/main/java/mltk/predictor/function/BivariateFunction.java
================================================
package mltk.predictor.function;

/**
 * Interface for bivariate real functions.
 * 
 * @author Yin Lou
 * 
 */
public interface BivariateFunction {

	/**
	 * Computes the value for the function.
	 * 
	 * @param x the 1st argument.
	 * @param y the 2nd argument.
	 * @return the value for the function.
	 */
	public double evaluate(double x, double y);

}


================================================
FILE: src/main/java/mltk/predictor/function/CHistogram.java
================================================
package mltk.predictor.function;

/**
 * Class for cumulative histograms.
 * 
 * @author Yin Lou
 * 
 */
public class CHistogram {

	public double[] sum;
	public double[] count;
	public double sumOnMV;
	public double countOnMV;

	/**
	 * Constructor.
	 * 
	 * @param n the size of this cumulative histogram.
	 */
	public CHistogram(int n) {
		sum = new double[n];
		count = new double[n];
		sumOnMV = 0.0;
		countOnMV = 0.0;
	}

	/**
	 * Returns the size of this cumulative histogram.
	 * 
	 * @return the size of this cumulative histogram.
	 */
	public int size() {
		return sum.length;
	}
	
	/**
	 * Returns {@code true} if missing values are present.
	 * 
	 * @return {@code true} if missing values are present.
	 */
	public boolean hasMissingValue() {
		return countOnMV > 0;
	}

}


================================================
FILE: src/main/java/mltk/predictor/function/CompressionUtils.java
================================================
package mltk.predictor.function;

import mltk.core.Instance;
import mltk.predictor.BaggedEnsemble;
import mltk.predictor.BoostedEnsemble;
import mltk.predictor.Predictor;
import mltk.util.tuple.IntPair;

/**
 * Class for utility functions for compressing ensembles of univariate/bivariate functions.
 * 
 * @author Yin Lou
 * 
 */
public class CompressionUtils {

	/**
	 * Compresses a bagged ensemble of 1D functions to a single 1D function.
	 * 
	 * @param attIndex the attribute index of this regressor.
	 * @param baggedEnsemble the bagged ensemble.
	 * @return a single compressed 1D function.
	 */
	public static Function1D compress(int attIndex, BaggedEnsemble baggedEnsemble) {
		Function1D function = Function1D.getConstantFunction(attIndex, 0);
		for (int i = 0; i < baggedEnsemble.size(); i++) {
			Predictor predictor = baggedEnsemble.get(i);
			Function1D func = null;
			if (predictor instanceof Function1D) {
				func = (Function1D) predictor;
			} else {
				throw new IllegalArgumentException();
			}
			function.add(func);
		}
		function.divide(baggedEnsemble.size());
		return function;
	}

	/**
	 * Compresses a boosted ensemble to a single 1D function.
	 * 
	 * @param attIndex the attribute of this regressor.
	 * @param boostedEnsemble the boosted ensemble.
	 * @return a single compressed 1D function.
	 */
	public static Function1D compress(int attIndex, BoostedEnsemble boostedEnsemble) {
		Function1D function = Function1D.getConstantFunction(attIndex, 0);
		for (int i = 0; i < boostedEnsemble.size(); i++) {
			Predictor predictor = boostedEnsemble.get(i);
			Function1D func = null;
			if (predictor instanceof Function1D) {
				func = (Function1D) predictor;
			} else if (predictor instanceof BaggedEnsemble) {
				func = compress(attIndex, (BaggedEnsemble) predictor);
			} else {
				throw new IllegalArgumentException();
			}
			function.add(func);
		}
		return function;
	}

	/**
	 * Converts a 1D function to 1D lookup table.
	 * 
	 * @param n the number of bins.
	 * @param function the 1D function.
	 * @return a 1D lookup table.
	 */
	public static Array1D convert(int n, Function1D function) {
		double[] predictions = new double[n];
		for (int i = 0; i < predictions.length; i++) {
			predictions[i] = function.evaluate(i);
		}
		return new Array1D(function.getAttributeIndex(), predictions, function.predictionOnMV);
	}

	/**
	 * Compresses a bagged ensemble of 2D functions to a single 2D function.
	 * 
	 * @param attIndex1 the 1st attribute index.
	 * @param attIndex2 the 2nd attribute index.
	 * @param baggedEnsemble the bagged ensemble.
	 * @return a single compressed 2D functions.
	 */
	public static Function2D compress(int attIndex1, int attIndex2, BaggedEnsemble baggedEnsemble) {
		// TODO check consistency problem when missing values are present.
		Function2D function = Function2D.getConstantFunction(attIndex1, attIndex2, 0);
		for (int i = 0; i < baggedEnsemble.size(); i++) {
			Predictor predictor = baggedEnsemble.get(i);
			Function2D func = null;
			if (predictor instanceof Function2D) {
				func = (Function2D) predictor;
			} else {
				throw new IllegalArgumentException();
			}
			function.add(func);
		}
		function.divide(baggedEnsemble.size());
		return function;
	}

	/**
	 * Compresses a boosted ensemble to a single 2D function.
	 * 
	 * @param attIndex1 the 1st attribute index.
	 * @param attIndex2 the 2nd attribute index.
	 * @param boostedEnsemble the boosted ensemble.
	 * @return a single compressed 2D function.
	 */
	public static Function2D compress(int attIndex1, int attIndex2, BoostedEnsemble boostedEnsemble) {
		// TODO check consistency problem when missing values are present.
		Function2D function = Function2D.getConstantFunction(attIndex1, attIndex2, 0);
		for (int i = 0; i < boostedEnsemble.size(); i++) {
			Predictor predictor = boostedEnsemble.get(i);
			Function2D func = null;
			if (predictor instanceof Function2D) {
				func = (Function2D) predictor;
			} else if (predictor instanceof BaggedEnsemble) {
				func = compress(attIndex1, attIndex2, (BaggedEnsemble) predictor);
			} else {
				throw new IllegalArgumentException();
			}
			function.add(func);
		}
		return function;
	}
	
	/**
	 * Compresses and converts a boosted ensemble to a single 2D lookup table.
	 * 
	 * @param attIndex1 the 1st attribute index.
	 * @param attIndex2 the 2nd attribute index.
	 * @param boostedEnsemble the boosted ensemble.
	 * @return a 2D lookup table.
	 */
	public static Array2D compress(int attIndex1, int attIndex2, int n1, int n2, BoostedEnsemble boostedEnsemble) {
		double[][] predictions = new double[n1][n2];
		double[] predictionsOnMV1 = new double[n2];
		double[] predictionsOnMV2 = new double[n1];
		double[] vector = new double[Math.max(attIndex1, attIndex2) + 1];
		Instance instance = new Instance(vector);
		for (int i = 0; i < n1; i++) {
			vector[attIndex1] = i;
			vector[attIndex2] = Double.NaN;
			predictionsOnMV2[i] = boostedEnsemble.regress(instance);
			
			double[] preds = predictions[i];
			for (int j = 0; j < n2; j++) {
				vector[attIndex1] = Double.NaN;
				vector[attIndex2] = j;
				predictionsOnMV1[j] = boostedEnsemble.regress(instance);
				
				vector[attIndex1] = i;
				preds[j] = boostedEnsemble.regress(instance);
			}
		}
		vector[attIndex1] = Double.NaN;
		vector[attIndex2] = Double.NaN;
		return new Array2D(attIndex1, attIndex2, predictions,
				predictionsOnMV1, predictionsOnMV2, boostedEnsemble.regress(instance));
	}

	/**
	 * Converts a 2D function to 2D lookup table.
	 * 
	 * @param n1 the number of bins for 1st attribute.
	 * @param n2 the number of bins for 2nd attribute.
	 * @param function the 2D function.
	 * @return a 2D lookup table.
	 */
	public static Array2D convert(int n1, int n2, Function2D function) {
		double[][] predictions = new double[n1][n2];
		double[] predictionsOnMV1 = new double[n2];
		double[] predictionsOnMV2 = new double[n1];
		for (int i = 0; i < n1; i++) {
			predictionsOnMV2[i] = function.evaluate(i, Double.NaN);
			
			double[] preds = predictions[i];
			for (int j = 0; j < n2; j++) {
				predictionsOnMV1[j] = function.evaluate(Double.NaN, j);
				
				preds[j] = function.evaluate(i, j);
			}
		}
		IntPair attIndices = function.getAttributeIndices();
		return new Array2D(attIndices.v1, attIndices.v2, predictions,
				predictionsOnMV1, predictionsOnMV2, function.predictionOnMV12);
	}

}


================================================
FILE: src/main/java/mltk/predictor/function/CubicSpline.java
================================================
package mltk.predictor.function;

import java.io.BufferedReader;
import java.io.PrintWriter;
import java.util.Arrays;

import mltk.core.Instance;
import mltk.predictor.Regressor;
import mltk.util.ArrayUtils;

/**
 * Class for cubic splines. Given knots k, the cubic spline uses the following basis: 1, x, x^2, x^3, (x - k[i])_+^3.
 * 
 * @author Yin Lou
 * 
 */
public class CubicSpline implements Regressor, UnivariateFunction {

	protected int attIndex;
	protected double intercept;
	protected double[] knots;
	protected double[] w;

	/**
	 * Constructor.
	 * 
	 * @param attIndex the attribute index.
	 * @param intercept the intercept.
	 * @param knots the knots.
	 * @param w the coefficient vector.
	 */
	public CubicSpline(int attIndex, double intercept, double[] knots, double[] w) {
		this.attIndex = attIndex;
		this.intercept = intercept;
		this.knots = knots;
		this.w = w;
	}

	/**
	 * Constructor.
	 * 
	 * @param intercept the intercept.
	 * @param knots the knots.
	 * @param w the coefficient vector.
	 */
	public CubicSpline(double intercept, double[] knots, double[] w) {
		this(-1, intercept, knots, w);
	}

	/**
	 * Constructor.
	 * 
	 * @param knots the knots.
	 * @param w the coefficient vector.
	 */
	public CubicSpline(double[] knots, double[] w) {
		this(-1, 0, knots, w);
	}

	/**
	 * Construct a cubic spline with specified knots and all coefficients set to zero.
	 * 
	 * @param knots the knots.
	 */
	public CubicSpline(double[] knots) {
		this(-1, 0, knots, new double[knots.length + 3]);
	}

	/**
	 * Constructor.
	 */
	public CubicSpline() {

	}

	@Override
	public void read(BufferedReader in) throws Exception {
		attIndex = Integer.parseInt(in.readLine().split(": ")[1]);
		intercept = Double.parseDouble(in.readLine().split(": ")[1]);
		in.readLine();
		knots = ArrayUtils.parseDoubleArray(in.readLine());
		in.readLine();
		w = ArrayUtils.parseDoubleArray(in.readLine());
	}

	@Override
	public void write(PrintWriter out) throws Exception {
		out.printf("[Predictor: %s]\n", this.getClass().getCanonicalName());
		out.println("AttIndex: " + attIndex);
		out.println("Intercept: " + intercept);
		out.println("Knots: " + knots.length);
		out.println(Arrays.toString(knots));
		out.println("Coefficients: " + w.length);
		out.println(Arrays.toString(w));
	}

	@Override
	public double evaluate(double x) {
		double pred = intercept + w[0] * x + w[1] * x * x + w[2] * x * x * x;
		for (int i = 0; i < knots.length; i++) {
			pred += h(x, knots[i]) * w[i + 3];
		}
		return pred;
	}

	/**
	 * Calculate the basis.
	 * 
	 * @param x a real.
	 * @param k a knot.
	 * @return h(x, z), a basis in cubic spline.
	 */
	public static double h(double x, double k) {
		double t = x - k;
		if (t < 0) {
			return 0;
		}
		return t * t * t;
	}

	@Override
	public double regress(Instance instance) {
		return evaluate(instance.getValue(attIndex));
	}

	/**
	 * Returns the attribute index.
	 * 
	 * @return the attribute index.
	 */
	public int getAttributeIndex() {
		return attIndex;
	}

	/**
	 * Sets the attribute index.
	 * 
	 * @param attIndex the new attribute index.
	 */
	public void setAttributeIndex(int attIndex) {
		this.attIndex = attIndex;
	}

	/**
	 * Returns the coefficient vector.
	 * 
	 * @return the coefficient vector.
	 */
	public double[] getCoefficients() {
		return w;
	}

	/**
	 * Returns the knot vector.
	 * 
	 * @return the knot vector.
	 */
	public double[] getKnots() {
		return knots;
	}

	/**
	 * Returns the intercept.
	 * 
	 * @return the intercept.
	 */
	public double getIntercept() {
		return intercept;
	}

	@Override
	public CubicSpline copy() {
		double[] newW = w.clone();
		double[] newKnots = knots.clone();
		return new CubicSpline(attIndex, intercept, newW, newKnots);
	}

}


================================================
FILE: src/main/java/mltk/predictor/function/EnsembledLineCutter.java
================================================
package mltk.predictor.function;

import mltk.core.Attribute;
import mltk.core.Instances;
import mltk.predictor.BaggedEnsemble;
import mltk.predictor.Learner;

public abstract class EnsembledLineCutter extends Learner {
	
	protected int attIndex;

	protected int numIntervals;
	
	protected int baggingIters;
	
	protected boolean isClassification;

	@Override
	public BaggedEnsemble build(Instances instances) {
		return build(instances, attIndex, numIntervals);
	}
	
	/**
	 * Builds an 1D function ensemble.
	 * 
	 * @param instances the training set.
	 * @param attIndex the attribute index.
	 * @param numIntervals the number of intervals.
	 * @return an 1D function ensemble.
	 */
	public BaggedEnsemble build(Instances instances, int attIndex, int numIntervals) {
		Attribute attribute = instances.getAttributes().get(attIndex);
		return build(instances, attribute, numIntervals);
	}
	
	public abstract BaggedEnsemble build(Instances instances, Attribute attribute, int numIntervals);
	
	/**
	 * Returns the index in the attribute list of the training set.
	 * 
	 * @return the index in the attribute list of the training set.
	 */
	public int getAttributeIndex() {
		return attIndex;
	}
	
	/**
	 * Sets the index in the attribute list of the training set.
	 * 
	 * @param attIndex the attribute index.
	 */
	public void setAttributeIndex(int attIndex) {
		this.attIndex = attIndex;
	}
	
	/**
	 * Returns the number of bagging iterations.
	 * 
	 * @return the number of bagging iterations.
	 */
	public int getBaggingIters() {
		return baggingIters;
	}

	/**
	 * Sets the number of bagging iterations.
	 * 
	 * @param baggingIters the number of bagging iterations.
	 */
	public void setBaggingIters(int baggingIters) {
		this.baggingIters = baggingIters;
	}
	
	/**
	 * Returns {@code true} if it is a classification problem.
	 * 
	 * @return {@code true} if it is a classification problem.
	 */
	public boolean isClassification() {
		return isClassification;
	}
	
	/**
	 * Sets {@code true} if it is a classification problem.
	 * 
	 * @param isClassification {@code true} if it is a classification problem.
	 */
	public void setClassification(boolean isClassification) {
		this.isClassification = isClassification;
	}
	
	/**
	 * Returns the number of intervals.
	 * 
	 * @return the number of intervals.
	 */
	public int getNumIntervals() {
		return numIntervals;
	}

	/**
	 * Sets the number of intervals.
	 * 
	 * @param numIntervals the number of intervals.
	 */
	public void setNumIntervals(int numIntervals) {
		this.numIntervals = numIntervals;
	}

}


================================================
FILE: src/main/java/mltk/predictor/function/Function1D.java
================================================
package mltk.predictor.function;

import java.io.BufferedReader;
import java.io.PrintWriter;
import java.util.Arrays;

import mltk.core.Instance;
import mltk.predictor.Regressor;
import mltk.util.ArrayUtils;
import mltk.util.MathUtils;
import mltk.util.VectorUtils;

/**
 * Class for 1D functions.
 * 
 * <p>
 * This class represents a segmented 1D function. Segments are defined in split array. For example, [3, 5, +INF] defines
 * three segments: (-INF, 3], (3, 5], (5, +INF). The last value in the split array is always +INF. The prediction array
 * is the corresponding predictions for segments defined in splits.
 * </p>
 * 
 * @author Yin Lou
 * 
 */
public class Function1D implements Regressor, UnivariateFunction {

	/**
	 * Attribute index.
	 */
	protected int attIndex;

	/**
	 * Last value is always Double.POSITIVE_INFINITY. e.g. [3, 5, +INF] defines three segments: (-INF, 3], (3, 5], (5,
	 * +INF)
	 */
	protected double[] splits;

	/**
	 * Corresponding predictions for segments defined in splits.
	 */
	protected double[] predictions;
	
	/**
	 * Prediction on missing value.
	 */
	protected double predictionOnMV;

	/**
	 * Returns a constant 1D function.
	 * 
	 * @param attIndex the attribute index of this function.
	 * @param prediction the constant.
	 * @return a constant 1D function.
	 */
	public static Function1D getConstantFunction(int attIndex, double prediction) {
		Function1D func = new Function1D(attIndex, new double[] { Double.POSITIVE_INFINITY },
				new double[] { prediction });
		return func;
	}

	/**
	 * Resets this function to 0.
	 */
	public void setZero() {
		splits = new double[] { Double.POSITIVE_INFINITY };
		predictions = new double[] { 0 };
		predictionOnMV = 0.0;
	}

	/**
	 * Returns {@code true} if the function is 0.
	 * 
	 * @return {@code true} if the function is 0.
	 */
	public boolean isZero() {
		return ArrayUtils.isConstant(predictions, 0, predictions.length, 0)
				&& MathUtils.isZero(predictionOnMV);
	}

	/**
	 * Returns {@code true} if the function is constant.
	 * 
	 * @return {@code true} if the function is constant.
	 */
	public boolean isConstant() {
		return ArrayUtils.isConstant(predictions, 1, predictions.length, predictions[0])
				&& MathUtils.isZero(predictionOnMV - predictions[0]);
	}

	/**
	 * Multiplies this function with a constant.
	 * 
	 * @param c the constant.
	 * @return this function.
	 */
	public Function1D multiply(double c) {
		VectorUtils.multiply(predictions, c);
		predictionOnMV *= c;
		return this;
	}

	/**
	 * Divides this function with a constant.
	 * 
	 * @param c the constant.
	 * @return this function.
	 */
	public Function1D divide(double c) {
		VectorUtils.divide(predictions, c);
		predictionOnMV /= c;
		return this;
	}

	/**
	 * Adds this function with a constant.
	 * 
	 * @param c the constant.
	 * @return this function.
	 */
	public Function1D add(double c) {
		VectorUtils.add(predictions, c);
		predictionOnMV += c;
		return this;
	}

	/**
	 * Subtracts this function with a constant.
	 * 
	 * @param c the constant.
	 * @return this function.
	 */
	public Function1D subtract(double c) {
		VectorUtils.subtract(predictions, c);
		predictionOnMV -= c;
		return this;
	}

	/**
	 * Constructor.
	 */
	public Function1D() {

	}
	
	/**
	 * Constructor.
	 * 
	 * @param attIndex the attribute index.
	 * @param splits the splits.
	 * @param predictions the predictions.
	 */
	public Function1D(int attIndex, double[] splits, double[] predictions) {
		this(attIndex, splits, predictions, 0.0);
	}

	/**
	 * Constructor.
	 * 
	 * @param attIndex the attribute index.
	 * @param splits the splits.
	 * @param predictions the predictions.
	 * @param predictionOnMissing prediction on missing value;
	 */
	public Function1D(int attIndex, double[] splits, double[] predictions, double predictionOnMissing) {
		this.attIndex = attIndex;
		this.splits = splits;
		this.predictions = predictions;
		this.predictionOnMV = predictionOnMissing;
	}

	/**
	 * Adds this function whit another function.
	 * 
	 * @param func the other function.
	 * @return this function.
	 */
	public Function1D add(Function1D func) {
		if (attIndex != func.attIndex) {
			throw new IllegalArgumentException("Cannot add functions on different terms");
		}
		int[] insertionPoints = new int[func.splits.length - 1];
		int newElements = 0;
		for (int i = 0; i < insertionPoints.length; i++) {
			insertionPoints[i] = Arrays.binarySearch(splits, func.splits[i]);
			if (insertionPoints[i] < 0) {
				newElements++;
			}
		}
		if (newElements > 0) {
			double[] newSplits = new double[splits.length + newElements];
			System.arraycopy(splits, 0, newSplits, 0, splits.length);
			int k = splits.length;
			for (int i = 0; i < insertionPoints.length; i++) {
				if (insertionPoints[i] < 0) {
					newSplits[k++] = func.splits[i];
				}
			}
			Arrays.sort(newSplits);

			double[] newPredictions = new double[newSplits.length];
			for (int i = 0; i < newSplits.length; i++) {
				newPredictions[i] = this.evaluate(newSplits[i]) + func.evaluate(newSplits[i]);
			}
			splits = newSplits;
			predictions = newPredictions;
		} else {
			for (int i = 0; i < splits.length; i++) {
				predictions[i] += func.evaluate(splits[i]);
			}
		}
		this.predictionOnMV += func.predictionOnMV;
		return this;
	}

	/**
	 * Returns the attribute index.
	 * 
	 * @return the attribute index.
	 */
	public int getAttributeIndex() {
		return attIndex;
	}

	/**
	 * Sets the attribute index.
	 * 
	 * @param attIndex the new attribute index.
	 */
	public void setAttributeIndex(int attIndex) {
		this.attIndex = attIndex;
	}

	/**
	 * Returns the internal split array.
	 * 
	 * @return the internal split array.
	 */
	public double[] getSplits() {
		return splits;
	}

	/**
	 * Sets the split array.
	 * 
	 * @param splits the new split array.
	 */
	public void setSplits(double[] splits) {
		this.splits = splits;
	}

	/**
	 * Returns the internal prediction array.
	 * 
	 * @return the internal prediction array.
	 */
	public double[] getPredictions() {
		return predictions;
	}

	/**
	 * Sets the prediction array.
	 * 
	 * @param predictions the new prediction array.
	 */
	public void setPredictions(double[] predictions) {
		this.predictions = predictions;
	}
	
	/**
	 * Returns the prediction on missing value.
	 * 
	 * @return the prediction on missing value.
	 */
	public double getPredictionOnMV() {
		return predictionOnMV;
	}
	
	/**
	 * Sets the prediction on missing value.
	 * 
	 * @param predictionOnMV the prediction on missing value.
	 */
	public void setPredictionOnMV(double predictionOnMV) {
		this.predictionOnMV = predictionOnMV;
	}

	@Override
	public void read(BufferedReader in) throws Exception {
		String line = in.readLine();
		String[] data = line.split(": ");
		attIndex = Integer.parseInt(data[1]);

		line = in.readLine();
		data = line.split(": ");
		predictionOnMV = Double.parseDouble(data[1]);
		
		in.readLine();
		line = in.readLine();
		splits = ArrayUtils.parseDoubleArray(line);

		in.readLine();
		line = in.readLine();
		predictions = ArrayUtils.parseDoubleArray(line);
	}

	@Override
	public void write(PrintWriter out) throws Exception {
		out.printf("[Predictor: %s]\n", this.getClass().getCanonicalName());
		out.println("AttIndex: " + attIndex);
		out.println("PredictinOnMV: " + predictionOnMV);
		out.println("Splits: " + splits.length);
		out.println(Arrays.toString(splits));
		out.println("Predictions: " + predictions.length);
		out.println(Arrays.toString(predictions));
	}

	@Override
	public double regress(Instance instance) {
		return evaluate(instance.getValue(attIndex));
	}

	@Override
	public double evaluate(double x) {
		if (Double.isNaN(x)) {
			return predictionOnMV;
		} else {
			return predictions[getSegmentIndex(x)];
		}
	}

	@Override
	public Function1D copy() {
		double[] splitsCopy = Arrays.copyOf(splits, splits.length);
		double[] predictionsCopy = Arrays.copyOf(predictions, predictions.length);
		return new Function1D(attIndex, splitsCopy, predictionsCopy, predictionOnMV);
	}
	
	/**
	 * Returns the segment index given x.
	 * 
	 * @param x the search key.
	 * @return the segment index given x.
	 */
	protected int getSegmentIndex(double x) {
		// Assume x is not NaN
		return ArrayUtils.findInsertionPoint(splits, x);
	}

}


================================================
FILE: src/main/java/mltk/predictor/function/Function2D.java
================================================
package mltk.predictor.function;

import java.io.BufferedReader;
import java.io.PrintWriter;
import java.util.Arrays;

import mltk.core.Instance;
import mltk.predictor.Regressor;
import mltk.util.ArrayUtils;
import mltk.util.VectorUtils;
import mltk.util.tuple.IntPair;

/**
 * Class for 2D functions.
 * 
 * <p>
 * This class represents a segmented 2D function. Segments are defined in split arrays for the two attributes. For
 * example, [3, 5, +INF] defines three segments: (-INF, 3], (3, 5], (5, +INF). The last value in the split array is
 * always +INF. The prediction matrix is the corresponding predictions for segments defined in splits.
 * </p>
 * 
 * @author Yin Lou
 * 
 */
public class Function2D implements Regressor, BivariateFunction {

	/**
	 * First attribute index.
	 */
	protected int attIndex1;

	/**
	 * Second attribute index.
	 */
	protected int attIndex2;
	
	/**
	 * Last value is always Double.POSITIVE_INFINITY. e.g. [3, 5, +INF] defines three segments: (-INF, 3], (3, 5], (5,
	 * +INF)
	 */
	protected double[] splits1;
	protected double[] splits2;

	/**
	 * Predictions.
	 */
	protected double[][] predictions;
	
	/**
	 * Predictions on missing value for attribute 1.
	 */
	protected double[] predictionsOnMV1;
	
	/**
	 * Predictions on missing value for attribute 2.
	 */
	protected double[] predictionsOnMV2;
	
	/**
	 * Prediction when both attribute 1 and 2 are missing.
	 */
	protected double predictionOnMV12;
	

	/**
	 * Constructor.
	 */
	public Function2D() {

	}

	/**
	 * Constructor.
	 * 
	 * @param attIndex1 the 1st attribute index.
	 * @param attIndex2 the 2nd attribute index.
	 * @param splits1 the split array for the 1st attribute.
	 * @param splits2 the split array for the 2nd attribute.
	 * @param predictions the prediction matrix.
	 */
	public Function2D(int attIndex1, int attIndex2, double[] splits1, double[] splits2, double[][] predictions) {
		this(attIndex1, attIndex2, splits1, splits2, predictions, new double[splits2.length], new double[splits1.length], 0.0);
	}
	
	/**
	 * Constructor.
	 * 
	 * @param attIndex1 the 1st attribute index.
	 * @param attIndex2 the 2nd attribute index.
	 * @param splits1 the split array for the 1st attribute.
	 * @param splits2 the split array for the 2nd attribute.
	 * @param predictions the prediction matrix.
	 * @param predictionsOnMV1 the prediction array when the 1st attribute is missing.
	 * @param predictionsOnMV2 the prediction array when the 2nd attribute is missing.
	 * @param predictionOnMV12 the prediction when both attributes are missing.
	 */
	public Function2D(int attIndex1, int attIndex2,
			double[] splits1, double[] splits2, double[][] predictions,
			double[] predictionsOnMV1, double[] predictionsOnMV2, double predictionOnMV12) {
		this.attIndex1 = attIndex1;
		this.attIndex2 = attIndex2;
		this.predictions = predictions;
		this.splits1 = splits1;
		this.splits2 = splits2;
		this.predictionsOnMV1 = predictionsOnMV1;
		this.predictionsOnMV2 = predictionsOnMV2;
		this.predictionOnMV12 = predictionOnMV12;
	}

	/**
	 * Returns a constant 2D function.
	 * 
	 * @param attIndex1 the 1st attribute index.
	 * @param attIndex2 the 2nd attribute index.
	 * @param prediction the constant.
	 * @return a constant 2D function.
	 */
	public static Function2D getConstantFunction(int attIndex1, int attIndex2, double prediction) {
		Function2D func = new Function2D(attIndex1, attIndex2, new double[] { Double.POSITIVE_INFINITY },
				new double[] { Double.POSITIVE_INFINITY }, new double[][] { { prediction } });
		return func;
	}

	/**
	 * Returns the index of 1st attribute.
	 * 
	 * @return the index of 1st attribute.
	 */
	public int getAttributeIndex1() {
		return attIndex1;
	}

	/**
	 * Returns the index of 2nd attribute.
	 * 
	 * @return the index of 2nd attribute.
	 */
	public int getAttributeIndex2() {
		return attIndex2;
	}

	/**
	 * Returns the attribute indices pair.
	 * 
	 * @return the attribute indices pair.
	 */
	public IntPair getAttributeIndices() {
		return new IntPair(attIndex1, attIndex2);
	}

	/**
	 * Sets the attribute indices.
	 * 
	 * @param attIndex1 the new index for the 1st attribute.
	 * @param attIndex2 the new index for the 2nd attribute.
	 */
	public void setAttributeIndices(int attIndex1, int attIndex2) {
		this.attIndex1 = attIndex1;
		this.attIndex2 = attIndex2;
	}
	
	/**
	 * Returns the internal prediction matrix.
	 * 
	 * @return the internal prediction matrix.
	 */
	public double[][] getPredictions() {
		return predictions;
	}
	
	/**
	 * Sets the prediction matrix.
	 * 
	 * @param predictions the new prediction matrix.
	 */
	public void setPredictions(double[][] predictions) {
		this.predictions = predictions;
	}
	
	/**
	 * Returns the prediction array when the 1st attribute is missing.
	 * 
	 * @return the prediction array when the 1st attribute is missing.
	 */
	public double[] getPredictionsOnMV1() {
		return predictionsOnMV1;
	}
	
	/**
	 * Sets the prediction array when the 1st attribute is missing.
	 * 
	 * @param predictionsOnMV1 the new prediction array.
	 */
	public void setPredictionsOnMV1(double[] predictionsOnMV1) {
		this.predictionsOnMV1 = predictionsOnMV1;
	}
	
	/**
	 * Returns the prediction array when the 2nd attribute is missing.
	 * 
	 * @return the prediction array when the 2nd attribute is missing.
	 */
	public double[] getPredictionsOnMV2() {
		return predictionsOnMV2;
	}
	
	/**
	 * Sets the prediction array when the 2nd attribute is missing.
	 * 
	 * @param predictionsOnMV2 the new prediction array.
	 */
	public void setPredictionsOnMV2(double[] predictionsOnMV2) {
		this.predictionsOnMV2 = predictionsOnMV2;
	}
	
	/**
	 * Returns the prediction when both attributes are missing.
	 * 
	 * @return the prediction when both attributes are missing.
	 */
	public double getPredictionOnMV12() {
		return predictionOnMV12;
	}
	
	/**
	 * Sets the prediction when both attributes are missing.
	 * 
	 * @param predictionOnMV12 the new prediction.
	 */
	public void setPredictionOnMV12(double predictionOnMV12) {
		this.predictionOnMV12 = predictionOnMV12;
	}

	/**
	 * Multiplies this function with a constant.
	 * 
	 * @param c the constant.
	 * @return this function.
	 */
	public Function2D multiply(double c) {
		for (double[] preds : predictions) {
			VectorUtils.multiply(preds, c);
		}
		VectorUtils.multiply(predictionsOnMV1, c);
		VectorUtils.multiply(predictionsOnMV2, c);
		predictionOnMV12 *= c;
		return this;
	}

	/**
	 * Divides this function with a constant.
	 * 
	 * @param c the constant.
	 * @return this function.
	 */
	public Function2D divide(double c) {
		for (double[] preds : predictions) {
			VectorUtils.divide(preds, c);
		}
		VectorUtils.divide(predictionsOnMV1, c);
		VectorUtils.divide(predictionsOnMV2, c);
		predictionOnMV12 /= c;
		return this;
	}

	/**
	 * Adds this function with a constant.
	 * 
	 * @param c the constant.
	 * @return this function.
	 */
	public Function2D add(double c) {
		for (double[] preds : predictions) {
			VectorUtils.add(preds, c);
		}
		VectorUtils.add(predictionsOnMV1, c);
		VectorUtils.add(predictionsOnMV2, c);
		predictionOnMV12 += c;
		return this;
	}

	/**
	 * Subtracts this function with a constant.
	 * 
	 * @param c the constant.
	 * @return this function.
	 */
	public Function2D subtract(double c) {
		for (double[] preds : predictions) {
			VectorUtils.subtract(preds, c);
		}
		VectorUtils.subtract(predictionsOnMV1, c);
		VectorUtils.subtract(predictionsOnMV2, c);
		predictionOnMV12 -= c;
		return this;
	}

	/**
	 * Adds this function with another one.
	 * 
	 * @param func the other function.
	 * @return this function.
	 */
	public Function2D add(Function2D func) {
		if (attIndex1 != func.attIndex1 || attIndex2 != func.attIndex2) {
			throw new IllegalArgumentException("Cannot add arrays on differnt terms");
		}
		double[] s1 = splits1;
		int[] insertionPoints1 = new int[func.splits1.length - 1];
		int newElements1 = 0;
		for (int i = 0; i < insertionPoints1.length; i++) {
			insertionPoints1[i] = Arrays.binarySearch(splits1, func.splits1[i]);
			if (insertionPoints1[i] < 0) {
				newElements1++;
			}
		}
		if (newElements1 > 0) {
			double[] newSplits1 = new double[splits1.length + newElements1];
			System.arraycopy(splits1, 0, newSplits1, 0, splits1.length);
			int k = splits1.length;
			for (int i = 0; i < insertionPoints1.length; i++) {
				if (insertionPoints1[i] < 0) {
					newSplits1[k++] = func.splits1[i];
				}
			}
			Arrays.sort(newSplits1);
			s1 = newSplits1;
		}
		double[] s2 = splits2;
		int[] insertionPoints2 = new int[func.splits2.length - 1];
		int newElements2 = 0;
		for (int j = 0; j < insertionPoints2.length; j++) {
			insertionPoints2[j] = Arrays.binarySearch(splits2, func.splits2[j]);
			if (insertionPoints2[j] < 0) {
				newElements2++;
			}
		}
		if (newElements2 > 0) {
			double[] newSplits2 = new double[splits2.length + newElements2];
			System.arraycopy(splits2, 0, newSplits2, 0, splits2.length);
			int k = splits2.length;
			for (int j = 0; j < insertionPoints2.length; j++) {
				if (insertionPoints2[j] < 0) {
					newSplits2[k++] = func.splits2[j];
				}
			}
			Arrays.sort(newSplits2);
			s2 = newSplits2;
		}

		if (newElements1 == 0 && newElements2 == 0) {
			for (int i = 0; i < splits1.length; i++) {
				predictionsOnMV2[i] += func.evaluate(splits1[i], Double.NaN);
				
				double[] ps = predictions[i];
				for (int j = 0; j < splits2.length; j++) {
					predictionsOnMV1[j] += func.evaluate(Double.NaN, splits2[j]);
					
					ps[j] += func.evaluate(splits1[i], splits2[j]);
				}
			}
			predictionOnMV12 += func.predictionOnMV12;
		} else {
			double[][] newPredictions = new double[s1.length][s2.length];
			predictionsOnMV1 = new double[s2.length];
			predictionsOnMV2 = new double[s1.length];
			for (int i = 0; i < s1.length; i++) {
				predictionsOnMV2[i] = this.evaluate(s1[i], Double.NaN) + func.evaluate(s1[i], Double.NaN);
				
				double[] ps = newPredictions[i];
				for (int j = 0; j < s2.length; j++) {
					predictionsOnMV1[j] = this.evaluate(Double.NaN, s2[j]) + func.evaluate(Double.NaN, s2[j]);
					
					ps[j] = this.evaluate(s1[i], s2[j]) + func.evaluate(s1[i], s2[j]);
				}
			}
			splits1 = s1;
			splits2 = s2;
			predictions = newPredictions;
			predictionOnMV12 = this.predictionOnMV12 + func.predictionOnMV12;
		}
		
		return this;
	}

	@Override
	public void read(BufferedReader in) throws Exception {
		String line = in.readLine();
		String[] data = line.split(": ");
		attIndex1 = Integer.parseInt(data[1]);
		line = in.readLine();
		data = line.split(": ");
		attIndex2 = Integer.parseInt(data[1]);

		in.readLine();
		line = in.readLine();
		splits1 = ArrayUtils.parseDoubleArray(line);

		in.readLine();
		line = in.readLine();
		splits2 = ArrayUtils.parseDoubleArray(line);

		String[] dim = in.readLine().split(": ")[1].split("x");
		predictions = new double[Integer.parseInt(dim[0])][];
		for (int i = 0; i < predictions.length; i++) {
			predictions[i] = ArrayUtils.parseDoubleArray(in.readLine());
		}
		
		in.readLine();
		predictionsOnMV1 = ArrayUtils.parseDoubleArray(in.readLine());
		
		in.readLine();
		predictionsOnMV2 = ArrayUtils.parseDoubleArray(in.readLine());
		
		data = in.readLine().split(": ");
		predictionOnMV12 = Double.parseDouble(data[1]);
	}

	@Override
	public void write(PrintWriter out) throws Exception {
		out.printf("[Predictor: %s]\n", this.getClass().getCanonicalName());
		out.println("AttIndex1: " + attIndex1);
		out.println("AttIndex2: " + attIndex2);
		out.println("Splits1: " + splits1.length);
		out.println(Arrays.toString(splits1));
		out.println("Splits2: " + splits2.length);
		out.println(Arrays.toString(splits2));
		out.println("Predictions: " + predictions.length + "x" + predictions[0].length);
		for (int i = 0; i < predictions.length; i++) {
			out.println(Arrays.toString(predictions[i]));
		}
		out.println("PredictionsOnMV1: " + predictionsOnMV1.length);
		out.println(Arrays.toString(predictionsOnMV1));
		out.println("PredictionsOnMV2: " + predictionsOnMV2.length);
		out.println(Arrays.toString(predictionsOnMV2));
		out.println("PredictionOnMV12: " + predictionOnMV12);
	}

	@Override
	public double regress(Instance instance) {
		return evaluate(instance.getValue(attIndex1), instance.getValue(attIndex2));
	}

	@Override
	public double evaluate(double x, double y) {
		if (!Double.isNaN(x) && !Double.isNaN(y)) {
			IntPair idx = getSegmentIndex(x, y);
			return predictions[idx.v1][idx.v2];
		} else if (Double.isNaN(x) && !Double.isNaN(y)) {
			int idx = ArrayUtils.findInsertionPoint(splits2, y);
			return predictionsOnMV1[idx];
		} else if (!Double.isNaN(x) && Double.isNaN(y)) {
			int idx = ArrayUtils.findInsertionPoint(splits1, x);
			return predictionsOnMV2[idx];
		} else {
			return predictionOnMV12;
		}
	}

	@Override
	public Function2D copy() {
		double[] splits1Copy = Arrays.copyOf(splits1, splits1.length);
		double[] splits2Copy = Arrays.copyOf(splits2, splits2.length);
		double[][] predictionsCopy = new double[predictions.length][];
		for (int i = 0; i < predictionsCopy.length; i++) {
			predictionsCopy[i] = Arrays.copyOf(predictions[i], predictions[i].length);
		}
		double[] predictionsOnMV1Copy = Arrays.copyOf(predictionsOnMV1, predictionsOnMV1.length);
		double[] predictionsOnMV2Copy = Arrays.copyOf(predictionsOnMV2, predictionsOnMV2.length);
		return new Function2D(attIndex1, attIndex2, splits1Copy, splits2Copy, predictionsCopy,
				predictionsOnMV1Copy, predictionsOnMV2Copy, predictionOnMV12);
	}
	
	/**
	 * Returns the segment indices pair given (x1, x2). Assume x1 and x2 are not missing values.
	 * 
	 * @param x1 the 1st search key.
	 * @param x2 the 2nd search key.
	 * @return segment indices pair at (x1, x2).
	 */
	protected IntPair getSegmentIndex(double x1, double x2) {
		int idx1 = ArrayUtils.findInsertionPoint(splits1, x1);
		int idx2 = ArrayUtils.findInsertionPoint(splits2, x2);
		return new IntPair(idx1, idx2);
	}

}


================================================
FILE: src/main
Download .txt
gitextract_ke00o21_/

├── .gitignore
├── LICENSE
├── README.md
├── pom.xml
└── src/
    ├── main/
    │   └── java/
    │       └── mltk/
    │           ├── cmdline/
    │           │   ├── Argument.java
    │           │   ├── CmdLineParser.java
    │           │   ├── options/
    │           │   │   ├── HoldoutValidatedLearnerOptions.java
    │           │   │   ├── HoldoutValidatedLearnerWithTaskOptions.java
    │           │   │   ├── LearnerOptions.java
    │           │   │   ├── LearnerWithTaskOptions.java
    │           │   │   └── package-info.java
    │           │   └── package-info.java
    │           ├── core/
    │           │   ├── Attribute.java
    │           │   ├── BinnedAttribute.java
    │           │   ├── Bins.java
    │           │   ├── Copyable.java
    │           │   ├── DenseVector.java
    │           │   ├── Instance.java
    │           │   ├── Instances.java
    │           │   ├── NominalAttribute.java
    │           │   ├── NumericalAttribute.java
    │           │   ├── Sampling.java
    │           │   ├── SparseVector.java
    │           │   ├── Vector.java
    │           │   ├── Writable.java
    │           │   ├── io/
    │           │   │   ├── AttributesReader.java
    │           │   │   ├── InstancesReader.java
    │           │   │   ├── InstancesWriter.java
    │           │   │   └── package-info.java
    │           │   ├── package-info.java
    │           │   └── processor/
    │           │       ├── Discretizer.java
    │           │       ├── InstancesSplitter.java
    │           │       ├── OneHotEncoder.java
    │           │       └── package-info.java
    │           ├── feature/
    │           │   └── selection/
    │           │       ├── BackwardElimination.java
    │           │       └── package-info.java
    │           ├── predictor/
    │           │   ├── BaggedEnsemble.java
    │           │   ├── BaggedEnsembleLearner.java
    │           │   ├── BoostedEnsemble.java
    │           │   ├── Classifier.java
    │           │   ├── Ensemble.java
    │           │   ├── Family.java
    │           │   ├── HoldoutValidatedLearner.java
    │           │   ├── Learner.java
    │           │   ├── LinkFunction.java
    │           │   ├── Predictor.java
    │           │   ├── ProbabilisticClassifier.java
    │           │   ├── Regressor.java
    │           │   ├── evaluation/
    │           │   │   ├── AUC.java
    │           │   │   ├── ConvergenceTester.java
    │           │   │   ├── Error.java
    │           │   │   ├── Evaluator.java
    │           │   │   ├── LogLoss.java
    │           │   │   ├── LogisticLoss.java
    │           │   │   ├── MAE.java
    │           │   │   ├── Metric.java
    │           │   │   ├── MetricFactory.java
    │           │   │   ├── Predictor.java
    │           │   │   ├── RMSE.java
    │           │   │   ├── SimpleMetric.java
    │           │   │   └── package-info.java
    │           │   ├── function/
    │           │   │   ├── Array1D.java
    │           │   │   ├── Array2D.java
    │           │   │   ├── BaggedLineCutter.java
    │           │   │   ├── BivariateFunction.java
    │           │   │   ├── CHistogram.java
    │           │   │   ├── CompressionUtils.java
    │           │   │   ├── CubicSpline.java
    │           │   │   ├── EnsembledLineCutter.java
    │           │   │   ├── Function1D.java
    │           │   │   ├── Function2D.java
    │           │   │   ├── Histogram2D.java
    │           │   │   ├── LineCutter.java
    │           │   │   ├── LinearFunction.java
    │           │   │   ├── SquareCutter.java
    │           │   │   ├── SubagSequence.java
    │           │   │   ├── SubaggedLineCutter.java
    │           │   │   ├── UnivariateFunction.java
    │           │   │   └── package-info.java
    │           │   ├── gam/
    │           │   │   ├── DenseDesignMatrix.java
    │           │   │   ├── GA2MLearner.java
    │           │   │   ├── GAM.java
    │           │   │   ├── GAMLearner.java
    │           │   │   ├── GAMUtils.java
    │           │   │   ├── SPLAMLearner.java
    │           │   │   ├── ScorecardModelLearner.java
    │           │   │   ├── SparseDesignMatrix.java
    │           │   │   ├── interaction/
    │           │   │   │   ├── FAST.java
    │           │   │   │   └── package-info.java
    │           │   │   ├── package-info.java
    │           │   │   └── tool/
    │           │   │       ├── Diagnostics.java
    │           │   │       ├── Visualizer.java
    │           │   │       └── package-info.java
    │           │   ├── glm/
    │           │   │   ├── ElasticNetLearner.java
    │           │   │   ├── GLM.java
    │           │   │   ├── GLMLearner.java
    │           │   │   ├── GLMOptimUtils.java
    │           │   │   ├── GroupLassoLearner.java
    │           │   │   ├── LassoLearner.java
    │           │   │   ├── RidgeLearner.java
    │           │   │   └── package-info.java
    │           │   ├── io/
    │           │   │   ├── PredictorReader.java
    │           │   │   ├── PredictorWriter.java
    │           │   │   └── package-info.java
    │           │   ├── package-info.java
    │           │   └── tree/
    │           │       ├── DecisionTable.java
    │           │       ├── DecisionTableLearner.java
    │           │       ├── RTree.java
    │           │       ├── RTreeLearner.java
    │           │       ├── RegressionTree.java
    │           │       ├── RegressionTreeLeaf.java
    │           │       ├── RegressionTreeLearner.java
    │           │       ├── TreeInteriorNode.java
    │           │       ├── TreeLearner.java
    │           │       ├── TreeNode.java
    │           │       ├── ensemble/
    │           │       │   ├── BaggedRTrees.java
    │           │       │   ├── BoostedDTables.java
    │           │       │   ├── BoostedRTrees.java
    │           │       │   ├── RTreeList.java
    │           │       │   ├── TreeEnsembleLearner.java
    │           │       │   ├── ag/
    │           │       │   │   ├── AdditiveGroves.java
    │           │       │   │   ├── AdditiveGrovesLearner.java
    │           │       │   │   └── package-info.java
    │           │       │   ├── brt/
    │           │       │   │   ├── BDT.java
    │           │       │   │   ├── BRT.java
    │           │       │   │   ├── BRTLearner.java
    │           │       │   │   ├── BRTUtils.java
    │           │       │   │   ├── LADBoostLearner.java
    │           │       │   │   ├── LSBoostLearner.java
    │           │       │   │   ├── LogitBoostLearner.java
    │           │       │   │   ├── RobustDecisionTableLearner.java
    │           │       │   │   ├── RobustRegressionTreeLearner.java
    │           │       │   │   └── package-info.java
    │           │       │   ├── package-info.java
    │           │       │   └── rf/
    │           │       │       ├── RandomForest.java
    │           │       │       ├── RandomForestLearner.java
    │           │       │       ├── RandomRegressionTreeLearner.java
    │           │       │       └── package-info.java
    │           │       └── package-info.java
    │           └── util/
    │               ├── ArrayUtils.java
    │               ├── Element.java
    │               ├── MathUtils.java
    │               ├── OptimUtils.java
    │               ├── Permutation.java
    │               ├── Queue.java
    │               ├── Random.java
    │               ├── Stack.java
    │               ├── StatUtils.java
    │               ├── UFSets.java
    │               ├── VectorUtils.java
    │               ├── package-info.java
    │               └── tuple/
    │                   ├── DoublePair.java
    │                   ├── IntDoublePair.java
    │                   ├── IntDoublePairComparator.java
    │                   ├── IntPair.java
    │                   ├── IntTriple.java
    │                   ├── LongDoublePair.java
    │                   ├── LongDoublePairComparator.java
    │                   ├── LongPair.java
    │                   ├── Pair.java
    │                   ├── Triple.java
    │                   └── package-info.java
    └── test/
        └── java/
            └── mltk/
                ├── core/
                │   ├── BinsTest.java
                │   ├── InstancesTestHelper.java
                │   ├── io/
                │   │   ├── AttributesReaderTest.java
                │   │   └── InstancesReaderTest.java
                │   └── processor/
                │       ├── DiscretizerTest.java
                │       └── InstancesSplitterTest.java
                ├── predictor/
                │   ├── evaluation/
                │   │   ├── AUCTest.java
                │   │   ├── ConvergenceTesterTest.java
                │   │   ├── ErrorTest.java
                │   │   ├── LogLossTest.java
                │   │   ├── LogisticLossTest.java
                │   │   ├── MAETest.java
                │   │   ├── MetricFactoryTest.java
                │   │   └── RMSETest.java
                │   ├── glm/
                │   │   └── GLMTest.java
                │   └── tree/
                │       ├── DecisionTableLearnerTest.java
                │       ├── DecisionTableTest.java
                │       ├── DecisionTableTestHelper.java
                │       ├── RegressionTreeLearnerTest.java
                │       ├── RegressionTreeTest.java
                │       ├── RegressionTreeTestHelper.java
                │       └── ensemble/
                │           ├── BoostedDTablesTest.java
                │           ├── BoostedRTreesTest.java
                │           └── brt/
                │               ├── BDTTest.java
                │               ├── BRTTest.java
                │               ├── BRTUtilsTest.java
                │               └── LogitBoostLearnerTest.java
                └── util/
                    ├── ArrayUtilsTest.java
                    ├── MathUtilsTest.java
                    ├── OptimUtilsTest.java
                    ├── StatUtilsTest.java
                    └── VectorUtilsTest.java
Download .txt
SYMBOL INDEX (1520 symbols across 168 files)

FILE: src/main/java/mltk/cmdline/CmdLineParser.java
  class CmdLineParser (line 15) | public class CmdLineParser {
    method CmdLineParser (line 29) | public CmdLineParser(Class<?> clazz, Object obj) {
    method parse (line 47) | public void parse(String[] args) throws IllegalArgumentException, Ille...
    method printUsage (line 86) | public void printUsage() {
    method processFields (line 105) | private void processFields(Field[] fields) {

FILE: src/main/java/mltk/cmdline/options/HoldoutValidatedLearnerOptions.java
  class HoldoutValidatedLearnerOptions (line 5) | public class HoldoutValidatedLearnerOptions extends LearnerOptions {

FILE: src/main/java/mltk/cmdline/options/HoldoutValidatedLearnerWithTaskOptions.java
  class HoldoutValidatedLearnerWithTaskOptions (line 5) | public class HoldoutValidatedLearnerWithTaskOptions extends HoldoutValid...

FILE: src/main/java/mltk/cmdline/options/LearnerOptions.java
  class LearnerOptions (line 5) | public class LearnerOptions {

FILE: src/main/java/mltk/cmdline/options/LearnerWithTaskOptions.java
  class LearnerWithTaskOptions (line 5) | public class LearnerWithTaskOptions extends LearnerOptions {

FILE: src/main/java/mltk/core/Attribute.java
  class Attribute (line 9) | public abstract class Attribute implements Comparable<Attribute>, Copyab...
    type Type (line 11) | public enum Type {
    method getType (line 37) | public final Type getType() {
    method getIndex (line 46) | public final int getIndex() {
    method setIndex (line 55) | public final void setIndex(int index) {
    method getName (line 64) | public final String getName() {
    method compareTo (line 68) | @Override
    method hashCode (line 73) | @Override
    method equals (line 83) | @Override
    method toString (line 104) | @Override

FILE: src/main/java/mltk/core/BinnedAttribute.java
  class BinnedAttribute (line 13) | public class BinnedAttribute extends Attribute {
    method BinnedAttribute (line 24) | public BinnedAttribute(String name, int numBins) {
    method BinnedAttribute (line 35) | public BinnedAttribute(String name, int numBins, int index) {
    method BinnedAttribute (line 49) | public BinnedAttribute(String name, Bins bins) {
    method BinnedAttribute (line 60) | public BinnedAttribute(String name, Bins bins, int index) {
    method copy (line 66) | @Override
    method getNumBins (line 78) | public int getNumBins() {
    method getBins (line 87) | public Bins getBins() {
    method toString (line 91) | public String toString() {
    method parse (line 106) | public static BinnedAttribute parse(String str) {

FILE: src/main/java/mltk/core/Bins.java
  class Bins (line 11) | public class Bins {
    method Bins (line 23) | protected Bins() {
    method Bins (line 33) | public Bins(double[] boundaries, double[] medians) {
    method size (line 46) | public int size() {
    method getIndex (line 56) | public int getIndex(double value) {
    method getValue (line 72) | public double getValue(int index) {
    method getBoundaries (line 81) | public double[] getBoundaries() {
    method getMedians (line 90) | public double[] getMedians() {

FILE: src/main/java/mltk/core/Copyable.java
  type Copyable (line 10) | public interface Copyable<T> {
    method copy (line 17) | public T copy();

FILE: src/main/java/mltk/core/DenseVector.java
  class DenseVector (line 11) | public class DenseVector implements Vector {
    method DenseVector (line 20) | public DenseVector(double[] values) {
    method getValue (line 24) | @Override
    method getValues (line 29) | @Override
    method getValues (line 34) | @Override
    method setValue (line 43) | @Override
    method setValue (line 48) | @Override
    method copy (line 55) | @Override
    method isSparse (line 61) | @Override

FILE: src/main/java/mltk/core/Instance.java
  class Instance (line 11) | public class Instance implements Copyable<Instance> {
    method Instance (line 24) | public Instance(double[] values, double target, double weight) {
    method Instance (line 38) | public Instance(int[] indices, double[] values, double target, double ...
    method Instance (line 51) | public Instance(Vector vector, double target, double weight) {
    method Instance (line 63) | public Instance(double[] values, double target) {
    method Instance (line 74) | public Instance(int[] indices, double[] values, double target) {
    method Instance (line 84) | public Instance(Vector vector, double target) {
    method Instance (line 93) | public Instance(double[] values) {
    method Instance (line 103) | public Instance(int[] indices, double[] values) {
    method Instance (line 113) | public Instance(Vector vector, double[] values) {
    method Instance (line 122) | public Instance(Instance instance) {
    method isSparse (line 133) | public boolean isSparse() {
    method getValue (line 143) | public final double getValue(int attIndex) {
    method getValues (line 152) | public final double[] getValues() {
    method getValues (line 162) | public final double[] getValues(int... attributes) {
    method setValue (line 172) | public final void setValue(int attIndex, double value) {
    method setValue (line 182) | public final void setValue(Attribute attribute, double value) {
    method setValue (line 192) | public final void setValue(int[] attributes, double[] v) {
    method copy (line 198) | @Override
    method clone (line 209) | public Instance clone() {
    method isMissing (line 219) | public boolean isMissing(int attIndex) {
    method getValue (line 229) | public double getValue(Attribute att) {
    method getVector (line 238) | public Vector getVector() {
    method getWeight (line 247) | public double getWeight() {
    method setWeight (line 256) | public void setWeight(double weight) {
    method getTarget (line 265) | public double getTarget() {
    method setTarget (line 274) | public void setTarget(double target) {
    method toString (line 281) | public String toString() {
    method print (line 307) | protected void print(StringBuilder sb, double v) {

FILE: src/main/java/mltk/core/Instances.java
  class Instances (line 16) | public class Instances implements Iterable<Instance>, Copyable<Instances> {
    method Instances (line 27) | public Instances(List<Attribute> attributes) {
    method Instances (line 37) | public Instances(List<Attribute> attributes, int capacity) {
    method Instances (line 47) | public Instances(List<Attribute> attributes, Attribute targetAtt) {
    method Instances (line 58) | public Instances(List<Attribute> attributes, Attribute targetAtt, int ...
    method Instances (line 69) | public Instances(Instances instances) {
    method add (line 80) | public void add(Instance instance) {
    method get (line 90) | public Instance get(int index) {
    method getTargetAttribute (line 99) | public final Attribute getTargetAttribute() {
    method setTargetAttribute (line 108) | public final void setTargetAttribute(Attribute targetAtt) {
    method iterator (line 112) | @Override
    method size (line 122) | public final int size() {
    method dimension (line 131) | public final int dimension() {
    method getAttributes (line 140) | public List<Attribute> getAttributes() {
    method getAttributes (line 150) | public List<Attribute> getAttributes(int... indices) {
    method setAttributes (line 163) | public void setAttributes(List<Attribute> attributes) {
    method clear (line 170) | public void clear() {
    method shuffle (line 177) | public void shuffle() {
    method shuffle (line 186) | public void shuffle(java.util.Random rand) {
    method copy (line 190) | @Override

FILE: src/main/java/mltk/core/NominalAttribute.java
  class NominalAttribute (line 9) | public class NominalAttribute extends Attribute {
    method NominalAttribute (line 19) | public NominalAttribute(String name, String[] states) {
    method NominalAttribute (line 30) | public NominalAttribute(String name, String[] states, int index) {
    method copy (line 37) | public NominalAttribute copy() {
    method getCardinality (line 48) | public int getCardinality() {
    method getState (line 58) | public String getState(int index) {
    method getStates (line 67) | public String[] getStates() {
    method toString (line 71) | public String toString() {
    method parse (line 87) | public static NominalAttribute parse(String str) {

FILE: src/main/java/mltk/core/NumericalAttribute.java
  class NumericalAttribute (line 9) | public class NumericalAttribute extends Attribute {
    method NumericalAttribute (line 16) | public NumericalAttribute(String name) {
    method NumericalAttribute (line 26) | public NumericalAttribute(String name, int index) {
    method copy (line 32) | public NumericalAttribute copy() {
    method toString (line 38) | public String toString() {
    method parse (line 48) | public static NumericalAttribute parse(String str) {

FILE: src/main/java/mltk/core/Sampling.java
  class Sampling (line 17) | public class Sampling {
    method createBootstrapSample (line 25) | public static Instances createBootstrapSample(Instances instances) {
    method createBootstrapSample (line 49) | public static void createBootstrapSample(Instances instances, Map<Inte...
    method createBootstrapSampleIndices (line 76) | public static IntPair[] createBootstrapSampleIndices(int n) {
    method createSubsample (line 98) | public static Instances createSubsample(Instances instances, int n) {
    method createBags (line 116) | public static Instances[] createBags(Instances instances, int b) {

FILE: src/main/java/mltk/core/SparseVector.java
  class SparseVector (line 11) | public class SparseVector implements Vector {
    method SparseVector (line 22) | public SparseVector(int[] indices, double[] values) {
    method copy (line 27) | @Override
    method getValue (line 34) | @Override
    method getValues (line 44) | @Override
    method getIndices (line 54) | public int[] getIndices() {
    method getValues (line 58) | @Override
    method setValue (line 67) | @Override
    method setValue (line 77) | @Override
    method isSparse (line 84) | @Override

FILE: src/main/java/mltk/core/Vector.java
  type Vector (line 9) | public interface Vector extends Copyable<Vector> {
    method getValue (line 17) | public double getValue(int index);
    method getValues (line 24) | public double[] getValues();
    method getValues (line 32) | public double[] getValues(int... indices);
    method setValue (line 40) | public void setValue(int index, double value);
    method setValue (line 48) | public void setValue(int[] indices, double[] v);
    method isSparse (line 55) | public boolean isSparse();
    method copy (line 62) | public Vector copy();

FILE: src/main/java/mltk/core/Writable.java
  type Writable (line 12) | public interface Writable {
    method read (line 20) | void read(BufferedReader in) throws Exception;
    method write (line 28) | void write(PrintWriter out) throws Exception;

FILE: src/main/java/mltk/core/io/AttributesReader.java
  class AttributesReader (line 23) | public class AttributesReader {
    method read (line 32) | public static Pair<List<Attribute>, Attribute> read(String attFile) th...
    method read (line 47) | public static Pair<List<Attribute>, Attribute> read(BufferedReader br)...

FILE: src/main/java/mltk/core/io/InstancesReader.java
  class InstancesReader (line 24) | public class InstancesReader {
    method read (line 35) | public static Instances read(String attFile, String dataFile) throws I...
    method read (line 48) | public static Instances read(String attFile, String dataFile, String d...
    method read (line 152) | public static Instances read(String file, int targetIndex) throws IOEx...
    method read (line 165) | public static Instances read(String file, int targetIndex, String deli...
    method parseDenseInstance (line 201) | static Instance parseDenseInstance(String[] data, int classIndex) {
    method parseSparseInstance (line 232) | private static Instance parseSparseInstance(String[] data, TreeSet<Int...
    method parseSparseInstance (line 251) | private static Instance parseSparseInstance(String[] data) {
    method assignTargetAttribute (line 268) | private static void assignTargetAttribute(Instances instances) {
    method parseDouble (line 299) | private static double parseDouble(String s) {

FILE: src/main/java/mltk/core/io/InstancesWriter.java
  class InstancesWriter (line 17) | public class InstancesWriter {
    method write (line 27) | public static void write(Instances instances, String attFile, String d...
    method write (line 47) | public static void write(Instances instances, String file) throws IOEx...

FILE: src/main/java/mltk/core/processor/Discretizer.java
  class Discretizer (line 27) | public class Discretizer {
    class Options (line 29) | static class Options {
    method main (line 71) | public static void main(String[] args) throws Exception {
    method computeBins (line 126) | public static Bins computeBins(double[] x, int maxNumBins) {
    method computeBins (line 144) | public static Bins computeBins(Instances instances, int attIndex, int ...
    method computeBins (line 162) | public static Bins computeBins(List<Element<Double>> list, int maxNumB...
    method discretize (line 230) | public static void discretize(Instances instances, int attIndex, Bins ...
    method discretize (line 250) | public static void discretize(Instances instances, int attIndex, int m...
    method getMedian (line 255) | static double getMedian(List<DoublePair> stats, int start, double midP...
    method getStats (line 266) | static void getStats(List<Element<Double>> list, List<DoublePair> stat...
    method Discretizer (line 290) | public Discretizer() {

FILE: src/main/java/mltk/core/processor/InstancesSplitter.java
  class InstancesSplitter (line 27) | public class InstancesSplitter {
    class Options (line 29) | static class Options {
    method main (line 66) | public static void main(String[] args) throws Exception {
    method createCrossValidationFolds (line 180) | public static Instances[][] createCrossValidationFolds(Instances insta...
    method createCrossValidationFolds (line 207) | public static Instances[][] createCrossValidationFolds(Instances insta...
    method createCrossValidationFolds (line 237) | public static Instances[][] createCrossValidationFolds(Instances insta...
    method createCrossValidationFolds (line 265) | public static Instances[][] createCrossValidationFolds(Instances insta...
    method split (line 294) | public static Instances[] split(Instances instances, double... ratios) {
    method split (line 329) | public static Instances[] split(Instances instances, double ratio) {
    method split (line 340) | public static Instances[] split(Instances instances, int k) {
    method split (line 363) | public static Instances[] split(Instances instances, String attToStrat...
    method split (line 376) | public static Instances[] split(Instances instances, String attToStrat...
    method split (line 414) | public static Instances[] split(Instances instances, String attToStrat...
    method getStrata (line 434) | private static List<List<Instance>> getStrata(Instances instances, Str...

FILE: src/main/java/mltk/core/processor/OneHotEncoder.java
  class OneHotEncoder (line 20) | public class OneHotEncoder {
    method process (line 29) | public Instances process(Instances instances) {

FILE: src/main/java/mltk/feature/selection/BackwardElimination.java
  class BackwardElimination (line 22) | public class BackwardElimination {
    method select (line 33) | public static Pair<List<Attribute>, DoublePair> select(Instances train...
    method select (line 84) | public static Pair<List<Attribute>, DoublePair> select(Instances train...
    method evaluateModel (line 124) | private static DoublePair evaluateModel(Instances trainSet, Instances ...
    method evaluateModel (line 137) | private static DoublePair evaluateModel(Instances trainSet, Instances ...

FILE: src/main/java/mltk/predictor/BaggedEnsemble.java
  class BaggedEnsemble (line 14) | public class BaggedEnsemble extends Ensemble {
    method BaggedEnsemble (line 19) | public BaggedEnsemble() {
    method BaggedEnsemble (line 28) | public BaggedEnsemble(int capacity) {
    method regress (line 32) | @Override
    method classify (line 46) | @Override
    method copy (line 74) | @Override

FILE: src/main/java/mltk/predictor/BaggedEnsembleLearner.java
  class BaggedEnsembleLearner (line 12) | public class BaggedEnsembleLearner extends Learner {
    method BaggedEnsembleLearner (line 24) | public BaggedEnsembleLearner(int baggingIters, Learner learner) {
    method getBaggingIterations (line 34) | public int getBaggingIterations() {
    method setBaggingIterations (line 43) | public void setBaggingIterations(int baggingIters) {
    method getLearner (line 52) | public Learner getLearner() {
    method setLearner (line 61) | public void setLearner(Learner learner) {
    method getBags (line 70) | public Instances[] getBags() {
    method setBags (line 79) | public void setBags(Instances[] bags) {
    method build (line 83) | @Override
    method build (line 101) | public BaggedEnsemble build(Instances[] bags) {

FILE: src/main/java/mltk/predictor/BoostedEnsemble.java
  class BoostedEnsemble (line 11) | public class BoostedEnsemble extends Ensemble {
    method BoostedEnsemble (line 16) | public BoostedEnsemble() {
    method BoostedEnsemble (line 25) | public BoostedEnsemble(int capacity) {
    method regress (line 29) | @Override
    method classify (line 39) | @Override
    method remove (line 54) | public void remove(int index) {
    method removeLast (line 61) | public void removeLast() {
    method copy (line 67) | @Override

FILE: src/main/java/mltk/predictor/Classifier.java
  type Classifier (line 11) | public interface Classifier extends Predictor {
    method classify (line 19) | public int classify(Instance instance);

FILE: src/main/java/mltk/predictor/Ensemble.java
  class Ensemble (line 14) | public abstract class Ensemble implements Classifier, Regressor {
    method Ensemble (line 21) | public Ensemble() {
    method Ensemble (line 30) | public Ensemble(int capacity) {
    method get (line 40) | public Predictor get(int index) {
    method getPredictors (line 49) | public List<Predictor> getPredictors() {
    method add (line 58) | public void add(Predictor predictor) {
    method size (line 67) | public int size() {
    method clear (line 74) | public void clear() {
    method read (line 78) | @Override
    method write (line 94) | @Override

FILE: src/main/java/mltk/predictor/Family.java
  type Family (line 9) | public enum Family {
    method get (line 20) | public static Family get(String name) {
    method Family (line 32) | Family(String name, LinkFunction link) {
    method getDefaultLinkFunction (line 42) | public LinkFunction getDefaultLinkFunction() {
    method toString (line 49) | public String toString() {

FILE: src/main/java/mltk/predictor/HoldoutValidatedLearner.java
  class HoldoutValidatedLearner (line 13) | public abstract class HoldoutValidatedLearner extends Learner {
    method HoldoutValidatedLearner (line 22) | public HoldoutValidatedLearner() {
    method getValidSet (line 31) | public Instances getValidSet() {
    method setValidSet (line 40) | public void setValidSet(Instances validSet) {
    method getMetric (line 49) | public Metric getMetric() {
    method setMetric (line 58) | public void setMetric(Metric metric) {
    method getConvergenceTester (line 67) | public ConvergenceTester getConvergenceTester() {
    method setConvergenceTester (line 76) | public void setConvergenceTester(ConvergenceTester ct) {

FILE: src/main/java/mltk/predictor/Learner.java
  class Learner (line 26) | public abstract class Learner {
    method isVerbose (line 35) | public boolean isVerbose() {
    method setVerbose (line 44) | public void setVerbose(boolean verbose) {
    type Task (line 52) | public enum Task {
      method Task (line 65) | Task(String task) {
      method toString (line 72) | public String toString() {
      method get (line 82) | public static Task get(String name) {
      method getDefaultMetric (line 96) | public Metric getDefaultMetric() {
    method build (line 119) | public abstract Predictor build(Instances instances);
    method isSparse (line 127) | protected boolean isSparse(Instances instances) {
    method getSparseDataset (line 145) | protected SparseDataset getSparseDataset(Instances instances, boolean ...
    method getDenseDataset (line 241) | protected DenseDataset getDenseDataset(Instances instances, boolean no...
    class SparseDataset (line 306) | protected class SparseDataset {
      method SparseDataset (line 315) | SparseDataset(int[] attrs, int[][] indices, double[][] values, doubl...
    class DenseDataset (line 331) | protected class DenseDataset {
      method DenseDataset (line 339) | DenseDataset(int[] attrs, double[][] x, double[] y, double[] stdList...

FILE: src/main/java/mltk/predictor/LinkFunction.java
  type LinkFunction (line 11) | public enum LinkFunction {
    method get (line 22) | public static LinkFunction get(String name) {
    method LinkFunction (line 33) | LinkFunction(String name) {
    method applyInverse (line 43) | public double applyInverse(double x) {
    method toString (line 61) | public String toString() {

FILE: src/main/java/mltk/predictor/Predictor.java
  type Predictor (line 15) | public interface Predictor extends Writable, Copyable<Predictor> {
    method read (line 23) | public void read(BufferedReader in) throws Exception;
    method write (line 31) | public void write(PrintWriter out) throws Exception;

FILE: src/main/java/mltk/predictor/ProbabilisticClassifier.java
  type ProbabilisticClassifier (line 11) | public interface ProbabilisticClassifier extends Classifier {
    method predictProbabilities (line 19) | public double[] predictProbabilities(Instance instance);

FILE: src/main/java/mltk/predictor/Regressor.java
  type Regressor (line 11) | public interface Regressor extends Predictor {
    method regress (line 19) | public double regress(Instance instance);

FILE: src/main/java/mltk/predictor/evaluation/AUC.java
  class AUC (line 15) | public class AUC extends SimpleMetric {
    class DoublePairComparator (line 17) | private class DoublePairComparator implements Comparator<DoublePair> {
      method compare (line 19) | @Override
    method AUC (line 33) | public AUC() {
    method eval (line 37) | @Override
    method eval (line 46) | @Override
    method eval (line 55) | protected double eval(DoublePair[] a) {

FILE: src/main/java/mltk/predictor/evaluation/ConvergenceTester.java
  class ConvergenceTester (line 12) | public class ConvergenceTester {
    method parse (line 28) | public static ConvergenceTester parse(String cc) {
    method ConvergenceTester (line 53) | public ConvergenceTester(int minNumPoints, double c) {
    method ConvergenceTester (line 63) | public ConvergenceTester(int minNumPoints, int n) {
    method ConvergenceTester (line 74) | public ConvergenceTester(int minNumPoints, int n, double c) {
    method ConvergenceTester (line 87) | public ConvergenceTester(int minNumPoints, int n, double c, int capaci...
    method getMetric (line 105) | public Metric getMetric() {
    method setMetric (line 114) | public void setMetric(Metric metric) {
    method add (line 126) | public void add(double measure) {
    method getBestIndex (line 140) | public int getBestIndex() {
    method getBestMetricValue (line 149) | public double getBestMetricValue() {
    method size (line 158) | public int size() {
    method getMeasureList (line 167) | public List<Double> getMeasureList() {
    method isConverged (line 176) | public boolean isConverged() {

FILE: src/main/java/mltk/predictor/evaluation/Error.java
  class Error (line 11) | public class Error extends SimpleMetric {
    method Error (line 16) | public Error() {
    method eval (line 20) | @Override
    method eval (line 33) | @Override

FILE: src/main/java/mltk/predictor/evaluation/Evaluator.java
  class Evaluator (line 22) | public class Evaluator {
    method evalAreaUnderROC (line 31) | public static double evalAreaUnderROC(ProbabilisticClassifier classifi...
    method evalRMSE (line 49) | public static double evalRMSE(List<Double> preds, List<Double> targets) {
    method evalRMSE (line 66) | public static double evalRMSE(Regressor regressor, Instances instances) {
    method evalError (line 86) | public static double evalError(Classifier classifier, Instances instan...
    method evalLogisticLoss (line 107) | public static double evalLogisticLoss(Regressor regressor, Instances i...
    method evalMAE (line 125) | public static double evalMAE(Regressor regressor, Instances instances) {
    class Options (line 138) | static class Options {
    method main (line 168) | public static void main(String[] args) throws Exception {

FILE: src/main/java/mltk/predictor/evaluation/LogLoss.java
  class LogLoss (line 12) | public class LogLoss extends SimpleMetric {
    method LogLoss (line 19) | public LogLoss() {
    method LogLoss (line 28) | public LogLoss(boolean isRawScore) {
    method eval (line 33) | @Override
    method eval (line 38) | @Override
    method isRawScore (line 53) | public boolean isRawScore() {

FILE: src/main/java/mltk/predictor/evaluation/LogisticLoss.java
  class LogisticLoss (line 12) | public class LogisticLoss extends SimpleMetric {
    method LogisticLoss (line 17) | public LogisticLoss() {
    method eval (line 21) | @Override
    method eval (line 26) | @Override

FILE: src/main/java/mltk/predictor/evaluation/MAE.java
  class MAE (line 11) | public class MAE extends SimpleMetric {
    method MAE (line 16) | public MAE() {
    method eval (line 20) | @Override
    method eval (line 30) | @Override

FILE: src/main/java/mltk/predictor/evaluation/Metric.java
  class Metric (line 14) | public abstract class Metric {
    method Metric (line 23) | public Metric(boolean isLargerBetter) {
    method isLargerBetter (line 32) | public boolean isLargerBetter() {
    method isFirstBetter (line 43) | public boolean isFirstBetter(double a, double b) {
    method worstValue (line 52) | public double worstValue() {
    method eval (line 67) | public abstract double eval(double[] preds, Instances instances);
    method searchBestMetricValueIndex (line 75) | public int searchBestMetricValueIndex(List<Double> list) {

FILE: src/main/java/mltk/predictor/evaluation/MetricFactory.java
  class MetricFactory (line 12) | public class MetricFactory {
    method getMetric (line 33) | public static Metric getMetric(String str) {

FILE: src/main/java/mltk/predictor/evaluation/Predictor.java
  class Predictor (line 25) | public class Predictor {
    class Options (line 27) | static class Options {
    method main (line 69) | public static void main(String[] args) throws Exception {
    method predict (line 168) | public static void predict(Regressor regressor, Instances instances, S...
    method predict (line 194) | public static void predict(Classifier classifier, Instances instances,...

FILE: src/main/java/mltk/predictor/evaluation/RMSE.java
  class RMSE (line 11) | public class RMSE extends SimpleMetric {
    method RMSE (line 16) | public RMSE() {
    method eval (line 20) | @Override
    method eval (line 31) | @Override

FILE: src/main/java/mltk/predictor/evaluation/SimpleMetric.java
  class SimpleMetric (line 9) | public abstract class SimpleMetric extends Metric {
    method SimpleMetric (line 16) | public SimpleMetric(boolean isLargerBetter) {
    method eval (line 27) | public abstract double eval(double[] preds, double[] targets);

FILE: src/main/java/mltk/predictor/function/Array1D.java
  class Array1D (line 17) | public class Array1D implements Regressor, UnivariateFunction {
    method Array1D (line 37) | public Array1D() {
    method Array1D (line 47) | public Array1D(int attIndex, double[] predictions) {
    method Array1D (line 58) | public Array1D(int attIndex, double[] predictions, double predictionOn...
    method getAttributeIndex (line 69) | public int getAttributeIndex() {
    method setAttributeIndex (line 78) | public void setAttributeIndex(int attIndex) {
    method getPredictions (line 87) | public double[] getPredictions() {
    method setPredictions (line 96) | public void setPredictions(double[] predictions) {
    method getPredictionOnMV (line 105) | public double getPredictionOnMV() {
    method setPredictionOnMV (line 114) | public void setPredictionOnMV(double predictionOnMV) {
    method read (line 118) | @Override
    method write (line 132) | @Override
    method regress (line 141) | @Override
    method add (line 157) | public Array1D add(Array1D ary) {
    method evaluate (line 168) | @Override
    method copy (line 177) | @Override

FILE: src/main/java/mltk/predictor/function/Array2D.java
  class Array2D (line 18) | public class Array2D implements Regressor, BivariateFunction {
    method Array2D (line 53) | public Array2D() {
    method Array2D (line 64) | public Array2D(int attIndex1, int attIndex2, double[][] predictions) {
    method Array2D (line 80) | public Array2D(int attIndex1, int attIndex2, double[][] predictions,
    method getAttributeIndex1 (line 95) | public int getAttributeIndex1() {
    method getAttributeIndex2 (line 104) | public int getAttributeIndex2() {
    method getAttributeIndices (line 113) | public IntPair getAttributeIndices() {
    method setAttributeIndices (line 123) | public void setAttributeIndices(int attIndex1, int attIndex2) {
    method getPredictions (line 133) | public double[][] getPredictions() {
    method setPredictions (line 142) | public void setPredictions(double[][] predictions) {
    method getPredictionsOnMV1 (line 151) | public double[] getPredictionsOnMV1() {
    method setPredictionsOnMV1 (line 160) | public void setPredictionsOnMV1(double[] predictionsOnMV1) {
    method getPredictionsOnMV2 (line 169) | public double[] getPredictionsOnMV2() {
    method setPredictionsOnMV2 (line 178) | public void setPredictionsOnMV2(double[] predictionsOnMV2) {
    method getPredictionOnMV12 (line 187) | public double getPredictionOnMV12() {
    method setPredictionOnMV12 (line 196) | public void setPredictionOnMV12(double predictionOnMV12) {
    method read (line 200) | @Override
    method write (line 225) | @Override
    method regress (line 241) | @Override
    method add (line 252) | public Array2D add(Array2D ary) {
    method evaluate (line 271) | @Override
    method copy (line 285) | @Override

FILE: src/main/java/mltk/predictor/function/BaggedLineCutter.java
  class BaggedLineCutter (line 24) | public class BaggedLineCutter extends EnsembledLineCutter {
    method BaggedLineCutter (line 31) | public BaggedLineCutter() {
    method BaggedLineCutter (line 40) | public BaggedLineCutter(boolean isClassification) {
    method createBags (line 51) | public void createBags(int n, int baggingIters) {
    method build (line 67) | @Override
    method build (line 72) | @Override

FILE: src/main/java/mltk/predictor/function/BivariateFunction.java
  type BivariateFunction (line 9) | public interface BivariateFunction {
    method evaluate (line 18) | public double evaluate(double x, double y);

FILE: src/main/java/mltk/predictor/function/CHistogram.java
  class CHistogram (line 9) | public class CHistogram {
    method CHistogram (line 21) | public CHistogram(int n) {
    method size (line 33) | public int size() {
    method hasMissingValue (line 42) | public boolean hasMissingValue() {

FILE: src/main/java/mltk/predictor/function/CompressionUtils.java
  class CompressionUtils (line 15) | public class CompressionUtils {
    method compress (line 24) | public static Function1D compress(int attIndex, BaggedEnsemble baggedE...
    method compress (line 47) | public static Function1D compress(int attIndex, BoostedEnsemble booste...
    method convert (line 71) | public static Array1D convert(int n, Function1D function) {
    method compress (line 87) | public static Function2D compress(int attIndex1, int attIndex2, Bagged...
    method compress (line 112) | public static Function2D compress(int attIndex1, int attIndex2, Booste...
    method compress (line 138) | public static Array2D compress(int attIndex1, int attIndex2, int n1, i...
    method convert (line 173) | public static Array2D convert(int n1, int n2, Function2D function) {

FILE: src/main/java/mltk/predictor/function/CubicSpline.java
  class CubicSpline (line 17) | public class CubicSpline implements Regressor, UnivariateFunction {
    method CubicSpline (line 32) | public CubicSpline(int attIndex, double intercept, double[] knots, dou...
    method CubicSpline (line 46) | public CubicSpline(double intercept, double[] knots, double[] w) {
    method CubicSpline (line 56) | public CubicSpline(double[] knots, double[] w) {
    method CubicSpline (line 65) | public CubicSpline(double[] knots) {
    method CubicSpline (line 72) | public CubicSpline() {
    method read (line 76) | @Override
    method write (line 86) | @Override
    method evaluate (line 97) | @Override
    method h (line 113) | public static double h(double x, double k) {
    method regress (line 121) | @Override
    method getAttributeIndex (line 131) | public int getAttributeIndex() {
    method setAttributeIndex (line 140) | public void setAttributeIndex(int attIndex) {
    method getCoefficients (line 149) | public double[] getCoefficients() {
    method getKnots (line 158) | public double[] getKnots() {
    method getIntercept (line 167) | public double getIntercept() {
    method copy (line 171) | @Override

FILE: src/main/java/mltk/predictor/function/EnsembledLineCutter.java
  class EnsembledLineCutter (line 8) | public abstract class EnsembledLineCutter extends Learner {
    method build (line 18) | @Override
    method build (line 31) | public BaggedEnsemble build(Instances instances, int attIndex, int num...
    method build (line 36) | public abstract BaggedEnsemble build(Instances instances, Attribute at...
    method getAttributeIndex (line 43) | public int getAttributeIndex() {
    method setAttributeIndex (line 52) | public void setAttributeIndex(int attIndex) {
    method getBaggingIters (line 61) | public int getBaggingIters() {
    method setBaggingIters (line 70) | public void setBaggingIters(int baggingIters) {
    method isClassification (line 79) | public boolean isClassification() {
    method setClassification (line 88) | public void setClassification(boolean isClassification) {
    method getNumIntervals (line 97) | public int getNumIntervals() {
    method setNumIntervals (line 106) | public void setNumIntervals(int numIntervals) {

FILE: src/main/java/mltk/predictor/function/Function1D.java
  class Function1D (line 25) | public class Function1D implements Regressor, UnivariateFunction {
    method getConstantFunction (line 55) | public static Function1D getConstantFunction(int attIndex, double pred...
    method setZero (line 64) | public void setZero() {
    method isZero (line 75) | public boolean isZero() {
    method isConstant (line 85) | public boolean isConstant() {
    method multiply (line 96) | public Function1D multiply(double c) {
    method divide (line 108) | public Function1D divide(double c) {
    method add (line 120) | public Function1D add(double c) {
    method subtract (line 132) | public Function1D subtract(double c) {
    method Function1D (line 141) | public Function1D() {
    method Function1D (line 152) | public Function1D(int attIndex, double[] splits, double[] predictions) {
    method Function1D (line 164) | public Function1D(int attIndex, double[] splits, double[] predictions,...
    method add (line 177) | public Function1D add(Function1D func) {
    method getAttributeIndex (line 220) | public int getAttributeIndex() {
    method setAttributeIndex (line 229) | public void setAttributeIndex(int attIndex) {
    method getSplits (line 238) | public double[] getSplits() {
    method setSplits (line 247) | public void setSplits(double[] splits) {
    method getPredictions (line 256) | public double[] getPredictions() {
    method setPredictions (line 265) | public void setPredictions(double[] predictions) {
    method getPredictionOnMV (line 274) | public double getPredictionOnMV() {
    method setPredictionOnMV (line 283) | public void setPredictionOnMV(double predictionOnMV) {
    method read (line 287) | @Override
    method write (line 306) | @Override
    method regress (line 317) | @Override
    method evaluate (line 322) | @Override
    method copy (line 331) | @Override
    method getSegmentIndex (line 344) | protected int getSegmentIndex(double x) {

FILE: src/main/java/mltk/predictor/function/Function2D.java
  class Function2D (line 25) | public class Function2D implements Regressor, BivariateFunction {
    method Function2D (line 68) | public Function2D() {
    method Function2D (line 81) | public Function2D(int attIndex1, int attIndex2, double[] splits1, doub...
    method Function2D (line 97) | public Function2D(int attIndex1, int attIndex2,
    method getConstantFunction (line 118) | public static Function2D getConstantFunction(int attIndex1, int attInd...
    method getAttributeIndex1 (line 129) | public int getAttributeIndex1() {
    method getAttributeIndex2 (line 138) | public int getAttributeIndex2() {
    method getAttributeIndices (line 147) | public IntPair getAttributeIndices() {
    method setAttributeIndices (line 157) | public void setAttributeIndices(int attIndex1, int attIndex2) {
    method getPredictions (line 167) | public double[][] getPredictions() {
    method setPredictions (line 176) | public void setPredictions(double[][] predictions) {
    method getPredictionsOnMV1 (line 185) | public double[] getPredictionsOnMV1() {
    method setPredictionsOnMV1 (line 194) | public void setPredictionsOnMV1(double[] predictionsOnMV1) {
    method getPredictionsOnMV2 (line 203) | public double[] getPredictionsOnMV2() {
    method setPredictionsOnMV2 (line 212) | public void setPredictionsOnMV2(double[] predictionsOnMV2) {
    method getPredictionOnMV12 (line 221) | public double getPredictionOnMV12() {
    method setPredictionOnMV12 (line 230) | public void setPredictionOnMV12(double predictionOnMV12) {
    method multiply (line 240) | public Function2D multiply(double c) {
    method divide (line 256) | public Function2D divide(double c) {
    method add (line 272) | public Function2D add(double c) {
    method subtract (line 288) | public Function2D subtract(double c) {
    method add (line 304) | public Function2D add(Function2D func) {
    method read (line 386) | @Override
    method write (line 419) | @Override
    method regress (line 439) | @Override
    method evaluate (line 444) | @Override
    method copy (line 460) | @Override
    method getSegmentIndex (line 481) | protected IntPair getSegmentIndex(double x1, double x2) {

FILE: src/main/java/mltk/predictor/function/Histogram2D.java
  class Histogram2D (line 13) | public class Histogram2D {
    class Table (line 24) | public static class Table {
      method Table (line 36) | public Table(int n, int m) {
    method computeHistogram2D (line 56) | public static void computeHistogram2D(Instances instances, int f1, int...
    method computeTable (line 88) | public static Table computeTable(Histogram2D hist2d, CHistogram cHist1...
    method fillTable (line 138) | protected static void fillTable(Table table, int i, int j, CHistogram ...
    method Histogram2D (line 156) | public Histogram2D(int n, int m) {
    method computeCHistogram (line 172) | public Pair<CHistogram, CHistogram> computeCHistogram() {

FILE: src/main/java/mltk/predictor/function/LineCutter.java
  class LineCutter (line 25) | public class LineCutter extends Learner {
    class Interval (line 27) | static class Interval implements Comparable<Interval> {
      method Interval (line 43) | Interval() {
      method Interval (line 47) | Interval(int start, int end, double sum, double weight) {
      method compareTo (line 55) | @Override
      method getPrediction (line 66) | double getPrediction() {
      method isFinalized (line 70) | boolean isFinalized() {
      method isInteriorNode (line 74) | boolean isInteriorNode() {
      method isLeaf (line 78) | boolean isLeaf() {
    method LineCutter (line 93) | public LineCutter() {
    method LineCutter (line 102) | public LineCutter(boolean isClassification) {
    method build (line 107) | @Override
    method build (line 120) | public Function1D build(Instances instances, Attribute attribute, int ...
    method build (line 208) | public Function1D build(Instances instances, int attIndex, int numInte...
    method getAttributeIndex (line 218) | public int getAttributeIndex() {
    method setAttributeIndex (line 227) | public void setAttributeIndex(int attIndex) {
    method isClassification (line 236) | public boolean isClassification() {
    method setClassification (line 245) | public void setClassification(boolean isClassification) {
    method getNumIntervals (line 254) | public int getNumIntervals() {
    method setNumIntervals (line 263) | public void setNumIntervals(int numIntervals) {
    method getHistograms (line 267) | protected static void getHistograms(List<Element<double[]>> pairs, Lis...
    method build (line 295) | protected static Function1D build(int attIndex, List<double[]> histogr...
    method sumUp (line 365) | protected static double[] sumUp(List<double[]> histograms, int start, ...
    method split (line 376) | protected static void split(List<double[]> histograms, Interval parent) {
    method split (line 380) | protected static void split(List<double[]> histograms, Interval parent...
    method inorder (line 436) | protected static void inorder(Interval parent, List<Double> splits, Li...

FILE: src/main/java/mltk/predictor/function/LinearFunction.java
  class LinearFunction (line 15) | public class LinearFunction implements Regressor, UnivariateFunction {
    method LinearFunction (line 30) | public LinearFunction() {
    method LinearFunction (line 39) | public LinearFunction(double beta) {
    method LinearFunction (line 49) | public LinearFunction(int attIndex, double beta) {
    method read (line 54) | @Override
    method write (line 60) | @Override
    method evaluate (line 67) | @Override
    method regress (line 72) | @Override
    method getSlope (line 77) | public double getSlope() {
    method setSlope (line 81) | public void setSlope(double beta) {
    method getAttributeIndex (line 85) | public int getAttributeIndex() {
    method copy (line 89) | @Override

FILE: src/main/java/mltk/predictor/function/SquareCutter.java
  class SquareCutter (line 21) | public class SquareCutter extends Learner {
    method SquareCutter (line 30) | public SquareCutter() {
    method SquareCutter (line 39) | public SquareCutter(boolean lineSearch) {
    method setAttIndices (line 49) | public void setAttIndices(int attIndex1, int attIndex2) {
    method build (line 54) | public Function2D build(Instances instances) {
    method findCuts (line 141) | protected static void findCuts(Histogram2D.Table table, int v1, int[] ...
    method findCuts (line 199) | protected static void findCuts(Histogram2D.Table table, int[] v1, int ...
    method getPredictor (line 257) | protected static void getPredictor(Histogram2D.Table table, int v1, in...
    method getPredictor (line 285) | protected static void getPredictor(Histogram2D.Table table, int[] v1, ...
    method getRSS (line 313) | protected static double getRSS(Histogram2D.Table table, int v1, int v2...
    method getRSS (line 355) | protected static double getRSS(Histogram2D.Table table, int[] v1, int ...
    method getFunction2D (line 398) | protected static Function2D getFunction2D(int attIndex1, int attIndex2...
    method getFunction2D (line 515) | protected static Function2D getFunction2D(int attIndex1, int attIndex2...
    method lineSearch (line 648) | protected static void lineSearch(Instances instances, int attIndex1, i...

FILE: src/main/java/mltk/predictor/function/SubagSequence.java
  class SubagSequence (line 17) | class SubagSequence {
    class SampleDelta (line 19) | static class SampleDelta {
      method SampleDelta (line 24) | SampleDelta(Set<Integer> toAdd, Set<Integer> toDel) {
      method getDistance (line 37) | int getDistance() {
    class Sample (line 43) | static class Sample {
      method Sample (line 48) | Sample(Set<Integer> set) {
      method computeDistance (line 57) | static int computeDistance(Sample s1, Sample s2) {
      method computeDelta (line 62) | static SampleDelta computeDelta(Sample s1, Sample s2) {
      method getWeight (line 71) | int getWeight() {
    method SubagSequence (line 83) | SubagSequence(int n, int m, int baggingIters) {
    method createSubsample (line 92) | Sample createSubsample(int n, int m) {
    method computeSequence (line 104) | private void computeSequence(Sample[] samples) {

FILE: src/main/java/mltk/predictor/function/SubaggedLineCutter.java
  class SubaggedLineCutter (line 22) | public class SubaggedLineCutter extends EnsembledLineCutter {
    method SubaggedLineCutter (line 31) | public SubaggedLineCutter() {
    method SubaggedLineCutter (line 40) | public SubaggedLineCutter(boolean isClassification) {
    method createSubags (line 52) | public void createSubags(int n, double subsampleRatio, int baggingIter...
    method build (line 57) | @Override
    class Histogram (line 62) | class Histogram {
      method Histogram (line 65) | Histogram(double[][] histogram) {
      method copy (line 69) | Histogram copy() {
    method build (line 90) | public BaggedEnsemble build(Instances instances, int attIndex, int num...
    method build (line 104) | public BaggedEnsemble build(Instances instances, Attribute attribute, ...
    method buildFromHistogram (line 220) | protected Function1D buildFromHistogram(int attIndex, Histogram histog...

FILE: src/main/java/mltk/predictor/function/UnivariateFunction.java
  type UnivariateFunction (line 9) | public interface UnivariateFunction {
    method evaluate (line 17) | public double evaluate(double x);

FILE: src/main/java/mltk/predictor/gam/DenseDesignMatrix.java
  class DenseDesignMatrix (line 10) | class DenseDesignMatrix {
    method DenseDesignMatrix (line 16) | DenseDesignMatrix(double[][][] x, double[][] knots, double[][] std) {
    method createCubicSplineDesignMatrix (line 22) | static DenseDesignMatrix createCubicSplineDesignMatrix(double[][] data...

FILE: src/main/java/mltk/predictor/gam/GA2MLearner.java
  class GA2MLearner (line 51) | public class GA2MLearner extends HoldoutValidatedLearner {
    class Options (line 53) | static class Options extends HoldoutValidatedLearnerWithTaskOptions {
    method main (line 99) | public static void main(String[] args) throws Exception {
    method GA2MLearner (line 174) | public GA2MLearner() {
    method getBaggingIters (line 188) | public int getBaggingIters() {
    method setBaggingIters (line 197) | public void setBaggingIters(int baggingIters) {
    method getMaxNumIters (line 206) | public int getMaxNumIters() {
    method setMaxNumIters (line 215) | public void setMaxNumIters(int maxNumIters) {
    method getLearningRate (line 224) | public double getLearningRate() {
    method setLearningRate (line 233) | public void setLearningRate(double learningRate) {
    method getTask (line 242) | public Task getTask() {
    method setTask (line 251) | public void setTask(Task task) {
    method getGAM (line 260) | public GAM getGAM() {
    method setGAM (line 269) | public void setGAM(GAM gam) {
    method getPairs (line 278) | public List<IntPair> getPairs() {
    method setPairs (line 287) | public void setPairs(List<IntPair> pairs) {
    method buildClassifier (line 300) | public void buildClassifier(GAM gam, List<IntPair> terms, Instances tr...
    method buildClassifier (line 447) | public void buildClassifier(GAM gam, List<IntPair> terms, Instances tr...
    method buildRegressor (line 563) | public void buildRegressor(GAM gam, List<IntPair> terms, Instances tra...
    method buildRegressor (line 708) | public void buildRegressor(GAM gam, List<IntPair> terms, Instances tra...
    method build (line 813) | @Override
    method indexOf (line 848) | private int indexOf(List<int[]> terms, IntPair pair) {

FILE: src/main/java/mltk/predictor/gam/GAM.java
  class GAM (line 22) | public class GAM implements ProbabilisticClassifier, Regressor {
    class RegressorList (line 24) | class RegressorList implements Iterable<Regressor> {
      method RegressorList (line 28) | RegressorList() {
      method iterator (line 32) | @Override
    class TermList (line 38) | class TermList implements Iterable<int[]> {
      method TermList (line 42) | TermList() {
      method iterator (line 46) | @Override
    method GAM (line 59) | public GAM() {
    method getIntercept (line 70) | public double getIntercept() {
    method setIntercept (line 79) | public void setIntercept(double intercept) {
    method read (line 83) | @Override
    method write (line 105) | @Override
    method add (line 125) | public void add(int[] term, Regressor regressor) {
    method regress (line 130) | @Override
    method classify (line 139) | @Override
    method predictProbabilities (line 145) | @Override
    method getTerms (line 157) | public List<int[]> getTerms() {
    method getRegressors (line 166) | public List<Regressor> getRegressors() {
    method copy (line 170) | @Override

FILE: src/main/java/mltk/predictor/gam/GAMLearner.java
  class GAMLearner (line 49) | public class GAMLearner extends HoldoutValidatedLearner {
    class Options (line 51) | static class Options extends HoldoutValidatedLearnerWithTaskOptions {
    method main (line 89) | public static void main(String[] args) throws Exception {
    method GAMLearner (line 147) | public GAMLearner() {
    method getBaggingIters (line 163) | public int getBaggingIters() {
    method setBaggingIters (line 172) | public void setBaggingIters(int baggingIters) {
    method getMaxNumIters (line 181) | public int getMaxNumIters() {
    method setMaxNumIters (line 190) | public void setMaxNumIters(int maxNumIters) {
    method getMaxNumLeaves (line 199) | public int getMaxNumLeaves() {
    method setMaxNumLeaves (line 208) | public void setMaxNumLeaves(int maxNumLeaves) {
    method getLearningRate (line 217) | public double getLearningRate() {
    method setLearningRate (line 226) | public void setLearningRate(double learningRate) {
    method getSubsamplingRatio (line 235) | public double getSubsamplingRatio() {
    method setSubsamplingRatio (line 244) | public void setSubsamplingRatio(double alpha) {
    method getTask (line 253) | public Task getTask() {
    method setTask (line 262) | public void setTask(Task task) {
    method setBaseLearner (line 271) | public void setBaseLearner(String option) {
    method buildClassifier (line 302) | public GAM buildClassifier(Instances trainSet, Instances validSet, int...
    method buildClassifier (line 444) | public GAM buildClassifier(Instances trainSet, int maxNumIters, int ma...
    method buildRegressor (line 559) | public GAM buildRegressor(Instances trainSet, Instances validSet, int ...
    method buildRegressor (line 695) | public GAM buildRegressor(Instances trainSet, int maxNumIters, int max...
    method build (line 792) | @Override

FILE: src/main/java/mltk/predictor/gam/GAMUtils.java
  class GAMUtils (line 13) | class GAMUtils {
    method getGAM (line 15) | static GAM getGAM(GLM glm, List<Attribute> attList) {

FILE: src/main/java/mltk/predictor/gam/SPLAMLearner.java
  class SPLAMLearner (line 33) | public class SPLAMLearner extends Learner {
    class Options (line 35) | static class Options extends LearnerWithTaskOptions {
    method main (line 73) | public static void main(String[] args) throws Exception {
    class ModelStructure (line 113) | static class ModelStructure {
      method ModelStructure (line 121) | ModelStructure(byte[] structure) {
      method equals (line 125) | @Override
      method hashCode (line 139) | @Override
    method SPLAMLearner (line 164) | public SPLAMLearner() {
    method build (line 176) | @Override
    method buildBinaryClassifier (line 210) | public GAM buildBinaryClassifier(int[] attrs, double[][][] x, double[]...
    method buildBinaryClassifier (line 310) | public GAM buildBinaryClassifier(int[] attrs, int[][] indices, double[...
    method buildClassifier (line 408) | public GAM buildClassifier(Instances trainSet, boolean isSparse, int n...
    method buildClassifier (line 508) | public GAM buildClassifier(Instances trainSet, int maxNumIters, int nu...
    method buildRegressor (line 523) | public GAM buildRegressor(Instances trainSet, boolean isSparse, int ma...
    method buildRegressor (line 623) | public GAM buildRegressor(Instances trainSet, int maxNumIters, int num...
    method buildRegressor (line 640) | public GAM buildRegressor(int[] attrs, double[][][] x, double[] y, dou...
    method buildRegressor (line 741) | public GAM buildRegressor(int[] attrs, int[][] indices, double[][][] v...
    method fitIntercept (line 839) | public boolean fitIntercept() {
    method fitIntercept (line 848) | public void fitIntercept(boolean fitIntercept) {
    method getAlpha (line 857) | public double getAlpha() {
    method getEpsilon (line 866) | public double getEpsilon() {
    method getLambda (line 875) | public double getLambda() {
    method getMaxNumIters (line 884) | public int getMaxNumIters() {
    method getNumKnots (line 893) | public int getNumKnots() {
    method getTask (line 902) | public Task getTask() {
    method isVerbose (line 911) | public boolean isVerbose() {
    method refit (line 920) | public boolean refit() {
    method refit (line 929) | public void refit(boolean refit) {
    method setAlpha (line 938) | public void setAlpha(double alpha) {
    method setEpsilon (line 947) | public void setEpsilon(double epsilon) {
    method setLambda (line 956) | public void setLambda(double lambda) {
    method setMaxNumIters (line 965) | public void setMaxNumIters(int maxNumIters) {
    method setNumKnots (line 974) | public void setNumKnots(int numKnots) {
    method setTask (line 983) | public void setTask(Task task) {
    method setVerbose (line 992) | public void setVerbose(boolean verbose) {
    method findMaxLambda (line 996) | public double findMaxLambda(Instances trainSet, Task task, int numKnot...
    method findMaxLambda (line 1029) | protected double findMaxLambda(double[][][] x, double[] rTrain, double...
    method findMaxLambda (line 1067) | protected double findMaxLambda(double[][][] x, double[] y, double[] pT...
    method testZeroPoint (line 1104) | protected boolean testZeroPoint(double[][][] x, double[] y, double[] t...
    method testZeroPoint (line 1152) | protected boolean testZeroPoint(double[][][] x, double[] y, double[] p...
    method computeGradient (line 1200) | protected void computeGradient(double[][] block, double[] rTrain, doub...
    method computeGradient (line 1206) | protected void computeGradient(int[] index, double[][] block, double[]...
    method doOnePass (line 1216) | protected boolean doOnePass(double[][][] x, double[] tl1, double[] tl2...
    method doOnePass (line 1287) | protected boolean doOnePass(double[][][] x, double[] y, double[] tl1, ...
    method doOnePass (line 1359) | protected boolean doOnePass(int[][] indices, double[][][] values, doub...
    method doOnePass (line 1431) | protected boolean doOnePass(int[][] indices, double[][][] values, doub...
    method extractStructure (line 1507) | protected byte[] extractStructure(double[][] w) {
    method getGAM (line 1525) | protected GAM getGAM(int[] attrs, double[][] knots, double[][] w, doub...
    method getPenalty (line 1546) | protected double getPenalty(double[] w, double lambda1, double lambda2) {
    method getPenalty (line 1557) | protected double getPenalty(double[][] coef, double[] lambda1, double[...
    method getRegularizationParameters (line 1565) | protected void getRegularizationParameters(double lambda, double alpha...
    method refitClassifier (line 1572) | protected GAM refitClassifier(int[] attrs, byte[] struct, double[][][]...
    method refitClassifier (line 1624) | protected GAM refitClassifier(int[] attrs, byte[] struct, int[][] indi...
    method refitRegressor (line 1684) | protected GAM refitRegressor(int[] attrs, byte[] struct, double[][][] ...
    method refitRegressor (line 1747) | protected GAM refitRegressor(int[] attrs, byte[] struct, int[][] indic...

FILE: src/main/java/mltk/predictor/gam/ScorecardModelLearner.java
  class ScorecardModelLearner (line 22) | public class ScorecardModelLearner extends Learner {
    class Options (line 24) | static class Options extends LearnerWithTaskOptions {
    method main (line 51) | public static void main(String[] args) throws Exception {
    method ScorecardModelLearner (line 89) | public ScorecardModelLearner() {
    method getLambda (line 102) | public double getLambda() {
    method setLambda (line 111) | public void setLambda(double lambda) {
    method getMaxNumIters (line 120) | public int getMaxNumIters() {
    method setMaxNumIters (line 129) | public void setMaxNumIters(int maxNumIters) {
    method getTask (line 138) | public Task getTask() {
    method setTask (line 147) | public void setTask(Task task) {
    method buildClassifier (line 159) | public GAM buildClassifier(Instances trainSet, int maxNumIters, double...
    method buildRegressor (line 181) | public GAM buildRegressor(Instances trainSet, int maxNumIters, double ...
    method build (line 195) | @Override

FILE: src/main/java/mltk/predictor/gam/SparseDesignMatrix.java
  class SparseDesignMatrix (line 10) | class SparseDesignMatrix {
    method SparseDesignMatrix (line 17) | SparseDesignMatrix(int[][] indices, double[][][] values, double[][] kn...
    method createCubicSplineDesignMatrix (line 24) | static SparseDesignMatrix createCubicSplineDesignMatrix(int n, int[][]...

FILE: src/main/java/mltk/predictor/gam/interaction/FAST.java
  class FAST (line 39) | public class FAST {
    class FASTThread (line 41) | static class FASTThread extends Thread {
      method FASTThread (line 46) | FASTThread(Instances instances) {
      method add (line 51) | public void add(Element<IntPair> pair) {
      method run (line 55) | public void run() {
    class Options (line 60) | static class Options {
    method main (line 98) | public static void main(String[] args) throws Exception {
    method computeWeights (line 175) | public static void computeWeights(Instances instances, List<Element<In...
    method computeCHistograms (line 211) | protected static double computeCHistograms(Instances instances, boolea...
    method computeWeight (line 242) | protected static void computeWeight(Element<IntPair> pair, CHistogram[...
    method getPredictor (line 265) | protected static void getPredictor(Histogram2D.Table table, int v1, in...
    method getRSS (line 280) | protected static double getRSS(Histogram2D.Table table, int v1, int v2...

FILE: src/main/java/mltk/predictor/gam/tool/Diagnostics.java
  class Diagnostics (line 28) | public class Diagnostics {
    type Mode (line 36) | public enum Mode {
      method Mode (line 49) | Mode(String mode) {
      method toString (line 53) | public String toString() {
      method getEnum (line 63) | public static Mode getEnum(String mode) {
    method diagnose (line 81) | public static List<Element<int[]>> diagnose(GAM gam, Instances instanc...
    method diagnose (line 92) | public static List<Element<int[]>> diagnose(GAM gam, Instances instanc...
    class Options (line 130) | static class Options {
    method main (line 164) | public static void main(String[] args) throws Exception {

FILE: src/main/java/mltk/predictor/gam/tool/Visualizer.java
  class Visualizer (line 38) | public class Visualizer {
    type Terminal (line 46) | public enum Terminal {
      method Terminal (line 59) | Terminal(String term) {
      method toString (line 63) | public String toString() {
      method getEnum (line 73) | public static Terminal getEnum(String term) {
    method generateGnuplotScripts (line 93) | public static void generateGnuplotScripts(GAM gam, Instances instances...
    class Options (line 474) | static class Options {
    method main (line 508) | public static void main(String[] args) throws Exception {

FILE: src/main/java/mltk/predictor/glm/ElasticNetLearner.java
  class ElasticNetLearner (line 28) | public class ElasticNetLearner extends GLMLearner {
    class Options (line 30) | static class Options extends LearnerWithTaskOptions {
    method main (line 61) | public static void main(String[] args) throws Exception {
    method ElasticNetLearner (line 98) | public ElasticNetLearner() {
    method build (line 104) | @Override
    method build (line 123) | @Override
    method buildBinaryClassifier (line 155) | public GLM buildBinaryClassifier(int[] attrs, double[][] x, double[] y...
    method buildBinaryClassifier (line 212) | public GLM buildBinaryClassifier(int[] attrs, int[][] indices, double[...
    method buildBinaryClassifiers (line 270) | public GLM[] buildBinaryClassifiers(int[] attrs, double[][] x, double[...
    method buildBinaryClassifiers (line 341) | public GLM[] buildBinaryClassifiers(int[] attrs, int[][] indices, doub...
    method buildClassifier (line 407) | public GLM buildClassifier(Instances trainSet, boolean isSparse, int m...
    method buildClassifier (line 519) | public GLM buildClassifier(Instances trainSet, int maxNumIters, double...
    method buildClassifiers (line 534) | public GLM[] buildClassifiers(Instances trainSet, boolean isSparse, in...
    method buildClassifiers (line 669) | public GLM[] buildClassifiers(Instances trainSet, int maxNumIters, int...
    method buildGaussianRegressor (line 684) | public GLM buildGaussianRegressor(Instances trainSet, boolean isSparse...
    method buildGaussianRegressor (line 722) | public GLM buildGaussianRegressor(Instances trainSet, int maxNumIters,...
    method buildGaussianRegressor (line 739) | public GLM buildGaussianRegressor(int[] attrs, double[][] x, double[] ...
    method buildGaussianRegressor (line 798) | public GLM buildGaussianRegressor(int[] attrs, int[][] indices, double...
    method buildGaussianRegressors (line 855) | public GLM[] buildGaussianRegressors(Instances trainSet, boolean isSpa...
    method buildGaussianRegressors (line 901) | public GLM[] buildGaussianRegressors(Instances trainSet, int maxNumIte...
    method buildGaussianRegressors (line 920) | public GLM[] buildGaussianRegressors(int[] attrs, double[][] x, double...
    method buildGaussianRegressors (line 997) | public GLM[] buildGaussianRegressors(int[] attrs, int[][] indices, dou...
    method doOnePassGaussian (line 1059) | protected void doOnePassGaussian(double[][] x, double[] sq, final doub...
    method doOnePassGaussian (line 1084) | protected void doOnePassGaussian(int[][] indices, double[][] values, d...
    method doOnePassBinomial (line 1114) | protected void doOnePassBinomial(double[][] x, double[] theta, double[...
    method doOnePassBinomial (line 1145) | protected void doOnePassBinomial(int[][] indices, double[][] values, d...
    method findMaxLambdaGaussian (line 1182) | protected double findMaxLambdaGaussian(double[][] x, double[] y, doubl...
    method findMaxLambdaGaussian (line 1203) | protected double findMaxLambdaGaussian(int[][] indices, double[][] val...
    method findMaxLambdaBinomial (line 1228) | protected double findMaxLambdaBinomial(double[][] x, double[] y, doubl...
    method findMaxLambdaBinomial (line 1253) | protected double findMaxLambdaBinomial(int[][] indices, double[][] val...
    method getL1Ratio (line 1287) | public double getL1Ratio() {
    method getLambda (line 1296) | public double getLambda() {
    method getTask (line 1305) | public Task getTask() {
    method setL1Ratio (line 1314) | public void setL1Ratio(double l1Ratio) {
    method setLambda (line 1323) | public void setLambda(double lambda) {
    method setTask (line 1332) | public void setTask(Task task) {

FILE: src/main/java/mltk/predictor/glm/GLM.java
  class GLM (line 22) | public class GLM implements ProbabilisticClassifier, Regressor {
    method GLM (line 42) | public GLM() {
    method GLM (line 51) | public GLM(int dimension) {
    method GLM (line 61) | public GLM(int numClasses, int dimension) {
    method GLM (line 72) | public GLM(double[] intercept, double[][] w) {
    method GLM (line 83) | public GLM(double[] intercept, double[][] w, LinkFunction link) {
    method coefficients (line 97) | public double[][] coefficients() {
    method coefficients (line 107) | public double[] coefficients(int k) {
    method intercept (line 116) | public double[] intercept() {
    method intercept (line 126) | public double intercept(int k) {
    method read (line 130) | @Override
    method write (line 145) | @Override
    method regress (line 162) | @Override
    method classify (line 167) | @Override
    method predict (line 179) | public double predict(Instance instance) {
    method predictProbabilities (line 183) | @Override
    method copy (line 207) | @Override
    method regress (line 216) | protected double regress(double intercept, double[] coef, Instance ins...

FILE: src/main/java/mltk/predictor/glm/GLMLearner.java
  class GLMLearner (line 14) | public abstract class GLMLearner extends Learner {
    method GLMLearner (line 24) | public GLMLearner() {
    method fitIntercept (line 37) | public boolean fitIntercept() {
    method fitIntercept (line 46) | public void fitIntercept(boolean fitIntercept) {
    method getEpsilon (line 55) | public double getEpsilon() {
    method setEpsilon (line 64) | public void setEpsilon(double epsilon) {
    method getMaxNumIters (line 73) | public int getMaxNumIters() {
    method setMaxNumIters (line 82) | public void setMaxNumIters(int maxNumIters) {
    method getFamily (line 91) | public Family getFamily() {
    method setFamily (line 100) | public void setFamily(Family family) {
    method build (line 112) | public abstract GLM build(Instances trainSet, Family family);

FILE: src/main/java/mltk/predictor/glm/GLMOptimUtils.java
  class GLMOptimUtils (line 8) | class GLMOptimUtils {
    method getGLM (line 10) | static GLM getGLM(int[] attrs, double[] w, double intercept, LinkFunct...
    method computeRidgeLoss (line 21) | static double computeRidgeLoss(double[] residual, double[] w, double l...
    method computeRidgeLoss (line 27) | static double computeRidgeLoss(double[] pred, double[] y, double[] w, ...
    method computeLassoLoss (line 33) | static double computeLassoLoss(double[] residual, double[] w, double l...
    method computeLassoLoss (line 39) | static double computeLassoLoss(double[] pred, double[] y, double[] w, ...
    method computeElasticNetLoss (line 45) | static double computeElasticNetLoss(double[] residual, double[] w, dou...
    method computeElasticNetLoss (line 51) | static double computeElasticNetLoss(double[] pred, double[] y, double[...
    method computeGroupLassoLoss (line 57) | static double computeGroupLassoLoss(double[] residual, double[][] w, d...
    method computeGroupLassoLoss (line 65) | static double computeGroupLassoLoss(double[] pred, double[] y, double[...

FILE: src/main/java/mltk/predictor/glm/GroupLassoLearner.java
  class GroupLassoLearner (line 35) | public class GroupLassoLearner extends GLMLearner {
    class DenseDesignMatrix (line 37) | class DenseDesignMatrix {
      method DenseDesignMatrix (line 42) | DenseDesignMatrix(int[][] groups, double[][][] x) {
    class ModelStructure (line 49) | static class ModelStructure {
      method ModelStructure (line 53) | ModelStructure(boolean[] structure) {
      method equals (line 57) | @Override
      method hashCode (line 71) | @Override
    class SparseDesignMatrix (line 81) | class SparseDesignMatrix {
      method SparseDesignMatrix (line 87) | SparseDesignMatrix(int[][] groups, int[][][] indices, double[][][] v...
    method GroupLassoLearner (line 102) | public GroupLassoLearner() {
    method build (line 109) | @Override
    method build (line 131) | @Override
    method buildBinaryClassifier (line 164) | public GLM buildBinaryClassifier(int[][] attrs, double[][][] x, double...
    method buildBinaryClassifier (line 269) | public GLM buildBinaryClassifier(int[][] attrs, int[][][] indices, dou...
    method buildBinaryClassifiers (line 392) | public List<GLM> buildBinaryClassifiers(int[][] attrs, double[][][] x,...
    method buildBinaryClassifiers (line 523) | public List<GLM> buildBinaryClassifiers(int[][] attrs, int[][][] indic...
    method buildClassifier (line 667) | public GLM buildClassifier(Instances trainSet, boolean isSparse, List<...
    method buildClassifier (line 782) | public GLM buildClassifier(Instances trainSet, List<int[]> groups, int...
    method buildClassifiers (line 797) | public List<GLM> buildClassifiers(Instances trainSet, boolean isSparse...
    method buildClassifiers (line 950) | public List<GLM> buildClassifiers(Instances trainSet, List<int[]> grou...
    method buildGaussianRegressor (line 965) | public GLM buildGaussianRegressor(Instances trainSet, boolean isSparse...
    method buildGaussianRegressor (line 1006) | public GLM buildGaussianRegressor(Instances trainSet, List<int[]> grou...
    method buildGaussianRegressor (line 1021) | public GLM buildGaussianRegressor(int[][] attrs, double[][][] x, doubl...
    method buildGaussianRegressor (line 1127) | public GLM buildGaussianRegressor(int[][] groups, int[][][] indices, d...
    method buildGaussianRegressors (line 1230) | public List<GLM> buildGaussianRegressors(Instances trainSet, boolean i...
    method buildGaussianRegressors (line 1277) | public List<GLM> buildGaussianRegressors(Instances trainSet, List<int[...
    method buildGaussianRegressors (line 1294) | public List<GLM> buildGaussianRegressors(int[][] groups, double[][][] ...
    method buildGaussianRegressors (line 1434) | public List<GLM> buildGaussianRegressors(int[][] groups, int[][][] ind...
    method getLambda (line 1566) | public double getLambda() {
    method getNumLambdas (line 1575) | public int getNumLambdas() {
    method getTask (line 1584) | public Task getTask() {
    method refit (line 1593) | public boolean refit() {
    method refit (line 1602) | public void refit(boolean refit) {
    method setLambda (line 1611) | public void setLambda(double lambda) {
    method setNumLambdas (line 1620) | public void setNumLambdas(int numLambdas) {
    method setTask (line 1629) | public void setTask(Task task) {
    method getGroups (line 1638) | public List<int[]> getGroups() {
    method setGroups (line 1647) | public void setGroups(List<int[]> groups) {
    method computeGradient (line 1651) | protected void computeGradient(double[][] block, double[] rTrain, doub...
    method computeGradient (line 1657) | protected void computeGradient(int[][] index, double[][] block, double...
    method computePenalty (line 1669) | protected double computePenalty(double[] w, double lambda) {
    method computePenalty (line 1673) | protected double computePenalty(double[][] w, double[] lambdas) {
    method createDesignMatrix (line 1681) | protected DenseDesignMatrix createDesignMatrix(DenseDataset dd, List<i...
    method createDesignMatrix (line 1718) | protected SparseDesignMatrix createDesignMatrix(SparseDataset sd, List...
    method doOnePassGaussian (line 1760) | protected boolean doOnePassGaussian(double[][][] x, double[] tl1, bool...
    method doOnePassGaussian (line 1811) | protected boolean doOnePassGaussian(int[][][] indices, double[][][] va...
    method doOnePassBinomial (line 1864) | protected boolean doOnePassBinomial(double[][][] x, double[] y, double...
    method doOnePassBinomial (line 1916) | protected boolean doOnePassBinomial(int[][][] indices, int[][] indexUn...
    method findMaxLambdaGaussian (line 1975) | protected double findMaxLambdaGaussian(double[][][] x, double[] rTrain...
    method findMaxLambdaGaussian (line 1994) | protected double findMaxLambdaGaussian(int[][][] indices, double[][][]...
    method findMaxLambdaBinomial (line 2015) | protected double findMaxLambdaBinomial(double[][][] x, double[] y, dou...
    method findMaxLambdaBinomial (line 2034) | protected double findMaxLambdaBinomial(int[][][] indices, double[][][]...
    method getGLM (line 2056) | protected GLM getGLM(int p, int[][] attrs, boolean[] selected, double[...
    method getGLM (line 2073) | protected GLM getGLM(int p, int[][] attrs, double[][] coef, double int...
    method refitClassifier (line 2088) | protected GLM refitClassifier(int p, int[][] groups, boolean[] selecte...
    method refitClassifier (line 2119) | protected GLM refitClassifier(int p, int[][] groups, boolean[] selecte...
    method refitGaussianRegressor (line 2157) | protected GLM refitGaussianRegressor(int p, int[][] attrs, boolean[] s...
    method refitGaussianRegressor (line 2199) | protected GLM refitGaussianRegressor(int p, int[][] groups, boolean[] ...

FILE: src/main/java/mltk/predictor/glm/LassoLearner.java
  class LassoLearner (line 32) | public class LassoLearner extends GLMLearner {
    class Options (line 34) | static class Options extends LearnerWithTaskOptions {
    method main (line 61) | public static void main(String[] args) throws Exception {
    class ModelStructure (line 90) | static class ModelStructure {
      method ModelStructure (line 94) | ModelStructure(boolean[] structure) {
      method equals (line 98) | @Override
      method hashCode (line 112) | @Override
    method LassoLearner (line 130) | public LassoLearner() {
    method build (line 137) | @Override
    method build (line 156) | @Override
    method buildBinaryClassifier (line 187) | public GLM buildBinaryClassifier(int[] attrs, double[][] x, double[] y...
    method buildBinaryClassifier (line 247) | public GLM buildBinaryClassifier(int[] attrs, int[][] indices, double[...
    method buildBinaryClassifiers (line 308) | public List<GLM> buildBinaryClassifiers(int[] attrs, double[][] x, dou...
    method buildBinaryClassifiers (line 390) | public List<GLM> buildBinaryClassifiers(int[] attrs, int[][] indices, ...
    method buildClassifier (line 467) | public GLM buildClassifier(Instances trainSet, boolean isSparse, int m...
    method buildClassifier (line 577) | public GLM buildClassifier(Instances trainSet, int maxNumIters, double...
    method buildClassifiers (line 591) | public List<GLM> buildClassifiers(Instances trainSet, boolean isSparse...
    method buildClassifiers (line 741) | public List<GLM> buildClassifiers(Instances trainSet, int maxNumIters,...
    method buildGaussianRegressor (line 754) | public GLM buildGaussianRegressor(Instances trainSet, boolean isSparse...
    method buildGaussianRegressor (line 791) | public GLM buildGaussianRegressor(Instances trainSet, int maxNumIters,...
    method buildGaussianRegressor (line 807) | public GLM buildGaussianRegressor(int[] attrs, double[][] x, double[] ...
    method buildGaussianRegressor (line 868) | public GLM buildGaussianRegressor(int[] attrs, int[][] indices, double...
    method buildGaussianRegressors (line 928) | public List<GLM> buildGaussianRegressors(Instances trainSet, boolean i...
    method buildGaussianRegressors (line 973) | public List<GLM> buildGaussianRegressors(Instances trainSet, int maxNu...
    method buildGaussianRegressors (line 990) | public List<GLM> buildGaussianRegressors(int[] attrs, double[][] x, do...
    method buildGaussianRegressors (line 1075) | public List<GLM> buildGaussianRegressors(int[] attrs, int[][] indices,...
    method doOnePassGaussian (line 1146) | protected void doOnePassGaussian(double[][] x, double[] sq, final doub...
    method doOnePassGaussian (line 1171) | protected void doOnePassGaussian(int[][] indices, double[][] values, d...
    method doOnePassBinomial (line 1201) | protected void doOnePassBinomial(double[][] x, double[] theta, double[...
    method doOnePassBinomial (line 1232) | protected void doOnePassBinomial(int[][] indices, double[][] values, d...
    method findMaxLambdaGaussian (line 1269) | protected double findMaxLambdaGaussian(double[][] x, double[] y) {
    method findMaxLambdaGaussian (line 1289) | protected double findMaxLambdaGaussian(int[][] indices, double[][] val...
    method findMaxLambdaBinomial (line 1313) | protected double findMaxLambdaBinomial(double[][] x, double[] y, doubl...
    method findMaxLambdaBinomial (line 1339) | protected double findMaxLambdaBinomial(int[][] indices, double[][] val...
    method getLambda (line 1372) | public double getLambda() {
    method getNumLambdas (line 1381) | public int getNumLambdas() {
    method getTask (line 1390) | public Task getTask() {
    method refit (line 1399) | public boolean refit() {
    method refit (line 1408) | public void refit(boolean refit) {
    method refitGaussianRegressor (line 1412) | protected GLM refitGaussianRegressor(int[] attrs, boolean[] selected, ...
    method refitGaussianRegressor (line 1455) | protected GLM refitGaussianRegressor(int[] attrs, boolean[] selected, ...
    method refitClassifier (line 1503) | protected GLM refitClassifier(int[] attrs, boolean[] selected, double[...
    method refitClassifier (line 1539) | protected GLM refitClassifier(int[] attrs, boolean[] selected, int[][]...
    method setLambda (line 1586) | public void setLambda(double lambda) {
    method setNumLambdas (line 1595) | public void setNumLambdas(int numLambdas) {
    method setTask (line 1604) | public void setTask(Task task) {

FILE: src/main/java/mltk/predictor/glm/RidgeLearner.java
  class RidgeLearner (line 26) | public class RidgeLearner extends GLMLearner {
    class Options (line 28) | static class Options extends LearnerWithTaskOptions {
    method main (line 55) | public static void main(String[] args) throws Exception {
    method RidgeLearner (line 90) | public RidgeLearner() {
    method build (line 95) | @Override
    method build (line 114) | @Override
    method buildBinaryClassifier (line 145) | public GLM buildBinaryClassifier(int[] attrs, double[][] x, double[] y...
    method buildBinaryClassifier (line 197) | public GLM buildBinaryClassifier(int[] attrs, int[][] indices, double[...
    method buildBinaryClassifiers (line 249) | public GLM[] buildBinaryClassifiers(int[] attrs, double[][] x, double[...
    method buildBinaryClassifiers (line 309) | public GLM[] buildBinaryClassifiers(int[] attrs, int[][] indices, doub...
    method buildClassifier (line 367) | public GLM buildClassifier(Instances trainSet, boolean isSparse, int m...
    method buildClassifier (line 477) | public GLM buildClassifier(Instances trainSet, int maxNumIters, double...
    method buildClassifiers (line 490) | public GLM[] buildClassifiers(Instances trainSet, boolean isSparse, in...
    method buildClassifiers (line 619) | public GLM[] buildClassifiers(Instances trainSet, int maxNumIters, dou...
    method buildGaussianRegressor (line 632) | public GLM buildGaussianRegressor(Instances trainSet, boolean isSparse...
    method buildGaussianRegressor (line 669) | public GLM buildGaussianRegressor(Instances trainSet, int maxNumIters,...
    method buildGaussianRegressor (line 685) | public GLM buildGaussianRegressor(int[] attrs, double[][] x, double[] ...
    method buildGaussianRegressor (line 738) | public GLM buildGaussianRegressor(int[] attrs, int[][] indices, double...
    method buildGaussianRegressors (line 789) | public GLM[] buildGaussianRegressors(Instances trainSet, boolean isSpa...
    method buildGaussianRegressors (line 831) | public GLM[] buildGaussianRegressors(Instances trainSet, int maxNumIte...
    method buildGaussianRegressors (line 847) | public GLM[] buildGaussianRegressors(int[] attrs, double[][] x, double...
    method buildGaussianRegressors (line 911) | public GLM[] buildGaussianRegressors(int[] attrs, int[][] indices, dou...
    method doOnePassGaussian (line 963) | protected void doOnePassGaussian(double[][] x, double[] sq, final doub...
    method doOnePassGaussian (line 980) | protected void doOnePassGaussian(int[][] indices, double[][] values, d...
    method doOnePassBinomial (line 1002) | protected void doOnePassBinomial(double[][] x, double[] theta, double[...
    method doOnePassBinomial (line 1024) | protected void doOnePassBinomial(int[][] indices, double[][] values, d...
    method getLambda (line 1057) | public double getLambda() {
    method getTask (line 1066) | public Task getTask() {
    method setLambda (line 1075) | public void setLambda(double lambda) {
    method setTask (line 1084) | public void setTask(Task task) {

FILE: src/main/java/mltk/predictor/io/PredictorReader.java
  class PredictorReader (line 14) | public class PredictorReader {
    method read (line 23) | public static Predictor read(String path) throws Exception {
    method read (line 43) | public static <T extends Predictor> T read(String path, Class<T> clazz...
    method read (line 55) | public static Predictor read(BufferedReader in) throws Exception {
    method read (line 73) | public static <T extends Predictor> T read(BufferedReader in, Class<T>...

FILE: src/main/java/mltk/predictor/io/PredictorWriter.java
  class PredictorWriter (line 13) | public class PredictorWriter {
    method write (line 22) | public static void write(Predictor predictor, String path) throws Exce...

FILE: src/main/java/mltk/predictor/tree/DecisionTable.java
  class DecisionTable (line 17) | public class DecisionTable implements RTree {
    method DecisionTable (line 27) | public DecisionTable() {
    method DecisionTable (line 39) | public DecisionTable(int[] attIndices, double[] splits,
    method getAttributeIndices (line 52) | public int[] getAttributeIndices() {
    method getSplits (line 61) | public double[] getSplits() {
    method multiply (line 65) | @Override
    method read (line 70) | @Override
    method write (line 82) | @Override
    method copy (line 95) | @Override
    method regress (line 104) | @Override
    method regress (line 125) | public double regress(long predIdx) {

FILE: src/main/java/mltk/predictor/tree/DecisionTableLearner.java
  class DecisionTableLearner (line 40) | public class DecisionTableLearner extends RTreeLearner {
    type Mode (line 48) | public enum Mode {
    method DecisionTableLearner (line 60) | public DecisionTableLearner() {
    method setParameters (line 66) | @Override
    method isRobust (line 90) | @Override
    method getConstructionMode (line 100) | public Mode getConstructionMode() {
    method setConstructionMode (line 109) | public void setConstructionMode(Mode mode) {
    method getMaxDepth (line 118) | public int getMaxDepth() {
    method setMaxDepth (line 127) | public void setMaxDepth(int maxDepth) {
    method getNumPasses (line 136) | public int getNumPasses() {
    method setNumPasses (line 145) | public void setNumPasses(int numPasses) {
    method build (line 149) | @Override
    method buildOnePassGreedy (line 174) | public DecisionTable buildOnePassGreedy(Instances instances, int maxDe...
    method buildMultiPassCyclic (line 324) | public DecisionTable buildMultiPassCyclic(Instances instances, int max...
    method buildMultiPassRandom (line 506) | public DecisionTable buildMultiPassRandom(Instances instances, int max...
    method processGains (line 685) | protected void processGains(List<Double> uniqueValues, double[] localG...
    method evalSplits (line 721) | protected double[] evalSplits(List<Double> uniqueValues, List<DoublePa...

FILE: src/main/java/mltk/predictor/tree/RTree.java
  type RTree (line 11) | public interface RTree extends Regressor {
    method multiply (line 18) | public void multiply(double c);
    method copy (line 23) | public RTree copy();

FILE: src/main/java/mltk/predictor/tree/RTreeLearner.java
  class RTreeLearner (line 17) | public abstract class RTreeLearner extends TreeLearner {
    method build (line 19) | @Override
    method getHistogram (line 22) | protected void getHistogram(Instances instances, List<IntDoublePair> p...
    method getStats (line 69) | protected boolean getStats(Instances instances, double[] stats) {

FILE: src/main/java/mltk/predictor/tree/RegressionTree.java
  class RegressionTree (line 14) | public class RegressionTree implements RTree {
    method RegressionTree (line 24) | public RegressionTree() {
    method RegressionTree (line 33) | public RegressionTree(TreeNode root) {
    method getRoot (line 42) | public TreeNode getRoot() {
    method setRoot (line 51) | public void setRoot(TreeNode root) {
    method getLeafNode (line 61) | public RegressionTreeLeaf getLeafNode(Instance instance) {
    method multiply (line 79) | public void multiply(double c) {
    method multiply (line 89) | protected void multiply(TreeNode node, double c) {
    method regress (line 100) | @Override
    method read (line 105) | @Override
    method write (line 113) | @Override
    method copy (line 120) | @Override

FILE: src/main/java/mltk/predictor/tree/RegressionTreeLeaf.java
  class RegressionTreeLeaf (line 12) | public class RegressionTreeLeaf extends TreeNode {
    method RegressionTreeLeaf (line 19) | public RegressionTreeLeaf() {
    method RegressionTreeLeaf (line 28) | public RegressionTreeLeaf(double prediction) {
    method isLeaf (line 32) | @Override
    method setPrediction (line 42) | public void setPrediction(double prediction) {
    method getPrediction (line 51) | public double getPrediction() {
    method read (line 55) | @Override
    method write (line 60) | @Override
    method copy (line 66) | @Override

FILE: src/main/java/mltk/predictor/tree/RegressionTreeLearner.java
  class RegressionTreeLearner (line 30) | public class RegressionTreeLearner extends RTreeLearner {
    class Options (line 32) | static class Options extends LearnerOptions {
    method main (line 58) | public static void main(String[] args) throws Exception {
    type Mode (line 90) | public enum Mode {
    method RegressionTreeLearner (line 104) | public RegressionTreeLearner() {
    method build (line 109) | @Override
    method setParameters (line 130) | @Override
    method isRobust (line 158) | @Override
    method getAlpha (line 168) | public double getAlpha() {
    method getConstructionMode (line 177) | public Mode getConstructionMode() {
    method getMaxDepth (line 186) | public int getMaxDepth() {
    method getMaxNumLeaves (line 195) | public int getMaxNumLeaves() {
    method getMinLeafSize (line 204) | public int getMinLeafSize() {
    method setAlpha (line 213) | public void setAlpha(double alpha) {
    method setConstructionMode (line 222) | public void setConstructionMode(Mode mode) {
    method setMaxDepth (line 231) | public void setMaxDepth(int maxDepth) {
    method setMaxNumLeaves (line 240) | public void setMaxNumLeaves(int maxNumLeaves) {
    method setMinLeafSize (line 249) | public void setMinLeafSize(int minLeafSize) {
    method buildAlphaLimitedTree (line 253) | protected RegressionTree buildAlphaLimitedTree(Instances instances, do...
    method buildDepthLimitedTree (line 258) | protected RegressionTree buildDepthLimitedTree(Instances instances, in...
    method buildMinLeafSizeLimitedTree (line 321) | protected RegressionTree buildMinLeafSizeLimitedTree(Instances instanc...
    method buildNumLeafLimitedTree (line 358) | protected RegressionTree buildNumLeafLimitedTree(Instances instances, ...
    method createNode (line 433) | protected TreeNode createNode(Dataset dataset, int limit, double[] sta...
    method split (line 482) | protected void split(Dataset data, TreeInteriorNode node, Dataset left...
    method split (line 486) | protected DoublePair split(List<Double> uniqueValues, List<DoublePair>...
    method traverse (line 519) | protected void traverse(TreeNode node, Map<TreeNode, TreeNode> parent) {

FILE: src/main/java/mltk/predictor/tree/TreeInteriorNode.java
  class TreeInteriorNode (line 14) | public class TreeInteriorNode extends TreeNode {
    method TreeInteriorNode (line 24) | public TreeInteriorNode() {
    method TreeInteriorNode (line 34) | public TreeInteriorNode(int attIndex, double splitPoint) {
    method getLeftChild (line 44) | public TreeNode getLeftChild() {
    method getRightChild (line 53) | public TreeNode getRightChild() {
    method getSplitAttributeIndex (line 62) | public int getSplitAttributeIndex() {
    method getSplitPoint (line 71) | public double getSplitPoint() {
    method isLeaf (line 75) | @Override
    method goLeft (line 86) | public boolean goLeft(Instance instance) {
    method read (line 91) | @Override
    method write (line 108) | @Override
    method copy (line 119) | @Override

FILE: src/main/java/mltk/predictor/tree/TreeLearner.java
  class TreeLearner (line 24) | public abstract class TreeLearner extends Learner {
    method isRobust (line 36) | public abstract boolean isRobust();
    method cache (line 44) | public void cache(Instances instances) {
    method evictCache (line 51) | public void evictCache() {
    method setParameters (line 60) | public abstract void setParameters(String mode);
    class Dataset (line 62) | protected static class Dataset {
      method create (line 64) | static Dataset create(Instances instances) {
      method create (line 105) | static Dataset create(Dataset dataset, Instances instances) {
      method Dataset (line 138) | Dataset() {
      method Dataset (line 142) | Dataset(Instances instances) {
      method merge (line 147) | static Dataset merge(Dataset left, Dataset right) {
      method split (line 197) | void split(int attIndex, double split, Dataset left, Dataset right) {

FILE: src/main/java/mltk/predictor/tree/TreeNode.java
  class TreeNode (line 12) | public abstract class TreeNode implements Writable, Copyable<TreeNode> {
    method isLeaf (line 19) | public abstract boolean isLeaf();

FILE: src/main/java/mltk/predictor/tree/ensemble/BaggedRTrees.java
  class BaggedRTrees (line 14) | public class BaggedRTrees extends RTreeList {
    method BaggedRTrees (line 19) | public BaggedRTrees() {
    method BaggedRTrees (line 28) | public BaggedRTrees(int n) {
    method regress (line 41) | public double regress(Instance instance) {

FILE: src/main/java/mltk/predictor/tree/ensemble/BoostedDTables.java
  class BoostedDTables (line 23) | public class BoostedDTables implements Copyable<BoostedDTables> {
    class IndexElement (line 25) | static class IndexElement implements Comparable<IndexElement> {
      method IndexElement (line 31) | public IndexElement(double cut, int tid, int pos) {
      method compareTo (line 37) | @Override
      method copy (line 42) | public IndexElement copy() {
    class Index (line 48) | static class Index {
      method Index (line 52) | public Index(IndexElement[] elements) {
      method setPredIdx (line 56) | void setPredIdx(long[] predIndices, double v) {
      method copy (line 68) | public Index copy() {
    method BoostedDTables (line 86) | public BoostedDTables() {
    method BoostedDTables (line 95) | public BoostedDTables(BoostedRTrees trees) {
    method buildIndex (line 106) | public void buildIndex() {
    method add (line 143) | public void add(DecisionTable dt) {
    method get (line 153) | public DecisionTable get(int index) {
    method removeLast (line 160) | public void removeLast() {
    method size (line 171) | public int size() {
    method set (line 181) | public void set(int index, DecisionTable dt) {
    method regress (line 191) | public double regress(Instance instance) {
    method copy (line 216) | @Override
    method copy (line 227) | public BoostedDTables copy(boolean copyIndexes) {
    method read (line 248) | public void read(BufferedReader in) throws Exception {
    method write (line 269) | public void write(PrintWriter out) throws Exception {

FILE: src/main/java/mltk/predictor/tree/ensemble/BoostedRTrees.java
  class BoostedRTrees (line 16) | public class BoostedRTrees extends RTreeList {
    method BoostedRTrees (line 21) | public BoostedRTrees() {
    method BoostedRTrees (line 30) | public BoostedRTrees(int n) {
    method regress (line 43) | public double regress(Instance instance) {
    method copy (line 51) | @Override
    method read (line 60) | public void read(BufferedReader in) throws Exception {
    method write (line 74) | public void write(PrintWriter out) throws Exception {

FILE: src/main/java/mltk/predictor/tree/ensemble/RTreeList.java
  class RTreeList (line 16) | public class RTreeList implements Iterable<RTree>, Copyable<RTreeList> {
    method RTreeList (line 23) | public RTreeList() {
    method RTreeList (line 32) | public RTreeList(int capacity) {
    method add (line 41) | public void add(RTree tree) {
    method copy (line 45) | @Override
    method get (line 60) | public RTree get(int index) {
    method iterator (line 64) | @Override
    method removeLast (line 72) | public void removeLast() {
    method set (line 84) | public void set(int index, RTree rt) {
    method size (line 93) | public int size() {

FILE: src/main/java/mltk/predictor/tree/ensemble/TreeEnsembleLearner.java
  class TreeEnsembleLearner (line 12) | public abstract class TreeEnsembleLearner extends HoldoutValidatedLearner {
    method getTreeLearner (line 16) | public TreeLearner getTreeLearner() {
    method setTreeLearner (line 20) | public void setTreeLearner(TreeLearner treeLearner) {

FILE: src/main/java/mltk/predictor/tree/ensemble/ag/AdditiveGroves.java
  class AdditiveGroves (line 18) | public class AdditiveGroves implements Regressor {
    method AdditiveGroves (line 25) | public AdditiveGroves() {
    method read (line 29) | @Override
    method write (line 49) | @Override
    method regress (line 63) | @Override
    method copy (line 77) | @Override

FILE: src/main/java/mltk/predictor/tree/ensemble/ag/AdditiveGrovesLearner.java
  class AdditiveGrovesLearner (line 39) | public class AdditiveGrovesLearner extends Learner {
    class Options (line 41) | static class Options extends LearnerOptions {
    method main (line 87) | public static void main(String[] args) throws Exception {
    class PerformanceMatrix (line 125) | class PerformanceMatrix {
      method PerformanceMatrix (line 130) | PerformanceMatrix(int maxNumTrees, int numAlphas, int baggingIters, ...
      method expand (line 135) | void expand(int maxNumTrees, int numAlphas, int baggingIters) {
      method eval (line 152) | void eval(int t, int a, int b, double[] preds, double[] targets) {
      method getBestParameters (line 156) | IntPair getBestParameters() {
      method analyzeBagging (line 188) | boolean analyzeBagging(int t, int a) {
    class ModelMatrix (line 194) | class ModelMatrix {
      method ModelMatrix (line 198) | ModelMatrix(int maxNumTrees, int numAlphas) {
      method expand (line 202) | void expand(int maxNumTrees, int numAlphas, int baggingIters) {
      method add (line 212) | void add(int t, int a, RegressionTree[] grove) {
    class PredictionMatrix (line 221) | class PredictionMatrix {
      method PredictionMatrix (line 226) | PredictionMatrix(int tn, int an, int n) {
      method expand (line 231) | void expand(int tn, int an) {
    method AdditiveGrovesLearner (line 257) | public AdditiveGrovesLearner() {
    method getMetric (line 270) | public SimpleMetric getMetric() {
    method setMetric (line 280) | public void setMetric(SimpleMetric metric) {
    method getBestNumTrees (line 291) | public int getBestNumTrees() {
    method getBestBaggingIters (line 300) | public int getBestBaggingIters() {
    method getBestAlpha (line 309) | public double getBestAlpha() {
    method getNumTrees (line 318) | public int getNumTrees() {
    method setNumTrees (line 327) | public void setNumTrees(int numTrees) {
    method getMinAlpha (line 336) | public double getMinAlpha() {
    method setMinAlpha (line 345) | public void setMinAlpha(double minAlpha) {
    method getBaggingIters (line 354) | public int getBaggingIters() {
    method setBaggingIters (line 363) | public void setBaggingIters(int baggingIters) {
    method buildRegressor (line 374) | public AdditiveGroves buildRegressor(Instances trainSet, Instances val...
    method runLayeredTraining (line 484) | public AdditiveGroves runLayeredTraining(Instances trainSet, int baggi...
    method build (line 531) | @Override
    method getAlpha (line 545) | protected double getAlpha(int an) {
    method getAlphaIdx (line 558) | protected int getAlphaIdx(double alpha, int n) {
    method backfit (line 567) | protected void backfit(Instances trainSet, double alpha, RegressionTre...
    method regress (line 615) | protected double regress(RegressionTree[] trees, Instance instance) {
    method runLayeredTraining (line 623) | protected void runLayeredTraining(Instances trainSet, Instances validS...
    method evalRMSE (line 680) | protected double evalRMSE(List<Integer> indices, double[] residual) {
    method update (line 690) | protected void update(Instances trainSet, RegressionTree[] grove, doub...

FILE: src/main/java/mltk/predictor/tree/ensemble/brt/BDT.java
  class BDT (line 26) | public class BDT implements ProbabilisticClassifier, Regressor {
    method constructBDT (line 36) | public static BDT constructBDT(BRT brt) {
    method BDT (line 50) | public BDT() {
    method BDT (line 59) | public BDT(int k) {
    method getDecisionTreeList (line 72) | public BoostedDTables getDecisionTreeList(int k) {
    method classify (line 76) | @Override
    method read (line 82) | @Override
    method write (line 95) | @Override
    method regress (line 105) | @Override
    method predictProbabilities (line 110) | @Override
    method copy (line 135) | @Override

FILE: src/main/java/mltk/predictor/tree/ensemble/brt/BRT.java
  class BRT (line 21) | public class BRT implements ProbabilisticClassifier, Regressor {
    method BRT (line 28) | public BRT() {
    method BRT (line 37) | public BRT(int k) {
    method getRegressionTreeList (line 50) | public BoostedRTrees getRegressionTreeList(int k) {
    method classify (line 54) | @Override
    method read (line 60) | @Override
    method write (line 73) | @Override
    method regress (line 83) | @Override
    method predictProbabilities (line 88) | @Override
    method copy (line 113) | @Override

FILE: src/main/java/mltk/predictor/tree/ensemble/brt/BRTLearner.java
  class BRTLearner (line 12) | public abstract class BRTLearner extends TreeEnsembleLearner {
    method BRTLearner (line 21) | public BRTLearner() {
    method getAlpha (line 39) | public double getAlpha() {
    method setAlpha (line 49) | public void setAlpha(double alpha) {
    method getLearningRate (line 58) | public double getLearningRate() {
    method setLearningRate (line 67) | public void setLearningRate(double learningRate) {
    method getMaxNumIters (line 76) | public int getMaxNumIters() {
    method setMaxNumIters (line 85) | public void setMaxNumIters(int maxNumIters) {

FILE: src/main/java/mltk/predictor/tree/ensemble/brt/BRTUtils.java
  class BRTUtils (line 7) | class BRTUtils {
    method parseTreeLearner (line 9) | public static TreeLearner parseTreeLearner(String baseLearner) {

FILE: src/main/java/mltk/predictor/tree/ensemble/brt/LADBoostLearner.java
  class LADBoostLearner (line 35) | public class LADBoostLearner extends BRTLearner {
    class Options (line 37) | static class Options extends HoldoutValidatedLearnerOptions {
    method main (line 74) | public static void main(String[] args) throws Exception {
    method LADBoostLearner (line 124) | public LADBoostLearner() {
    method build (line 128) | @Override
    method buildRegressor (line 148) | public BRT buildRegressor(Instances trainSet, Instances validSet, int ...
    method buildRegressor (line 262) | public BRT buildRegressor(Instances trainSet, int maxNumIters) {

FILE: src/main/java/mltk/predictor/tree/ensemble/brt/LSBoostLearner.java
  class LSBoostLearner (line 29) | public class LSBoostLearner extends BRTLearner {
    class Options (line 31) | static class Options extends HoldoutValidatedLearnerOptions {
    method main (line 68) | public static void main(String[] args) throws Exception {
    method LSBoostLearner (line 118) | public LSBoostLearner() {
    method build (line 122) | @Override
    method buildRegressor (line 142) | public BRT buildRegressor(Instances trainSet, Instances validSet, int ...
    method buildRegressor (line 235) | public BRT buildRegressor(Instances trainSet, int maxNumIters) {

FILE: src/main/java/mltk/predictor/tree/ensemble/brt/LogitBoostLearner.java
  class LogitBoostLearner (line 40) | public class LogitBoostLearner extends BRTLearner {
    class Options (line 42) | static class Options extends HoldoutValidatedLearnerOptions {
    method main (line 79) | public static void main(String[] args) throws Exception {
    method LogitBoostLearner (line 131) | public LogitBoostLearner() {
    method build (line 135) | @Override
    method buildBinaryClassifier (line 155) | public BRT buildBinaryClassifier(Instances trainSet, Instances validSe...
    method buildBinaryClassifier (line 274) | public BRT buildBinaryClassifier(Instances trainSet, int maxNumIters) {
    method buildClassifier (line 386) | public BRT buildClassifier(Instances trainSet, Instances validSet, int...
    method buildClassifier (line 526) | public BRT buildClassifier(Instances trainSet, int maxNumIters) {
    method setTreeLearner (line 648) | @Override
    method computeProbabilities (line 656) | protected void computeProbabilities(double[] pred, double[] prob) {
    method computeProbabilities (line 662) | protected void computeProbabilities(double[][] pred, double[][] prob) {

FILE: src/main/java/mltk/predictor/tree/ensemble/brt/RobustDecisionTableLearner.java
  class RobustDecisionTableLearner (line 18) | public class RobustDecisionTableLearner extends DecisionTableLearner {
    method getStats (line 20) | protected boolean getStats(Instances instances, double[] stats) {
    method getHistogram (line 44) | protected void getHistogram(Instances instances, List<IntDoublePair> p...

FILE: src/main/java/mltk/predictor/tree/ensemble/brt/RobustRegressionTreeLearner.java
  class RobustRegressionTreeLearner (line 19) | public class RobustRegressionTreeLearner extends RegressionTreeLearner {
    method isRobust (line 21) | public boolean isRobust() {
    method getStats (line 25) | protected boolean getStats(Instances instances, double[] stats) {
    method getHistogram (line 49) | protected void getHistogram(Instances instances, List<IntDoublePair> p...

FILE: src/main/java/mltk/predictor/tree/ensemble/rf/RandomForest.java
  class RandomForest (line 18) | public class RandomForest implements Regressor {
    method RandomForest (line 25) | public RandomForest() {
    method RandomForest (line 34) | public RandomForest(int capacity) {
    method read (line 38) | @Override
    method write (line 53) | @Override
    method copy (line 64) | @Override
    method regress (line 73) | @Override
    method add (line 91) | public void add(RTree rt) {
    method get (line 101) | public RTree get(int index) {
    method getTreeList (line 110) | public RTreeList getTreeList() {
    method size (line 119) | public int size() {

FILE: src/main/java/mltk/predictor/tree/ensemble/rf/RandomForestLearner.java
  class RandomForestLearner (line 20) | public class RandomForestLearner extends Learner {
    class Options (line 22) | static class Options extends LearnerOptions {
    method main (line 55) | public static void main(String[] args) throws Exception {
    method build (line 110) | @Override
    method RandomForestLearner (line 125) | public RandomForestLearner() {
    method getBaggingIterations (line 136) | public int getBaggingIterations() {
    method setBaggingIterations (line 145) | public void setBaggingIterations(int baggingIters) {
    method getRegressionTreeLearner (line 154) | public RegressionTreeLearner getRegressionTreeLearner() {
    method setRegressionTreeLearner (line 163) | public void setRegressionTreeLearner(RegressionTreeLearner rtLearner) {

FILE: src/main/java/mltk/predictor/tree/ensemble/rf/RandomRegressionTreeLearner.java
  class RandomRegressionTreeLearner (line 26) | public class RandomRegressionTreeLearner extends RegressionTreeLearner {
    method RandomRegressionTreeLearner (line 34) | public RandomRegressionTreeLearner() {
    method getNumFeatures (line 45) | public int getNumFeatures() {
    method setNumFeatures (line 54) | public void setNumFeatures(int numFeatures) {
    method build (line 58) | @Override
    method createNode (line 85) | protected TreeNode createNode(Dataset dataset, int limit, double[] sta...

FILE: src/main/java/mltk/util/ArrayUtils.java
  class ArrayUtils (line 12) | public class ArrayUtils {
    method toIntArray (line 20) | public static int[] toIntArray(List<Integer> list) {
    method toDoubleArray (line 34) | public static double[] toDoubleArray(List<Double> list) {
    method toIntArray (line 48) | public static int[] toIntArray(double[] a) {
    method toString (line 64) | public static String toString(double[] a, int start, int end) {
    method parseDoubleArray (line 80) | public static double[] parseDoubleArray(String str) {
    method parseDoubleArray (line 91) | public static double[] parseDoubleArray(String str, String delimiter) {
    method parseIntArray (line 109) | public static int[] parseIntArray(String str) {
    method parseIntArray (line 120) | public static int[] parseIntArray(String str, String delimiter) {
    method parseLongArray (line 138) | public static long[] parseLongArray(String str) {
    method parseLongArray (line 149) | public static long[] parseLongArray(String str, String delimiter) {
    method isConstant (line 170) | public static boolean isConstant(double[] a, int begin, int end, doubl...
    method isConstant (line 188) | public static boolean isConstant(int[] a, int begin, int end, int c) {
    method isConstant (line 206) | public static boolean isConstant(byte[] a, int begin, int end, byte c) {
    method getMedian (line 221) | public static double getMedian(double[] a) {
    method findInsertionPoint (line 242) | public static int findInsertionPoint(double[] a, double key) {

FILE: src/main/java/mltk/util/Element.java
  class Element (line 10) | public class Element<T> implements Comparable<Element<T>> {
    method Element (line 21) | public Element(T element, double weight) {
    method compareTo (line 26) | @Override

FILE: src/main/java/mltk/util/MathUtils.java
  class MathUtils (line 9) | public class MathUtils {
    method equals (line 28) | public static boolean equals(double a, double b) {
    method indicator (line 38) | public static int indicator(boolean b) {
    method isFirstBetter (line 50) | public static boolean isFirstBetter(double a, double b, boolean isLarg...
    method isInteger (line 64) | public static boolean isInteger(double v) {
    method isZero (line 74) | public static boolean isZero(double v) {
    method sigmoid (line 84) | public static double sigmoid(double a) {
    method sign (line 94) | public static int sign(double a) {
    method sign (line 110) | public static int sign(int a) {
    method divide (line 128) | public static double divide(double a, double b, double dv) {

FILE: src/main/java/mltk/util/OptimUtils.java
  class OptimUtils (line 11) | public class OptimUtils {
    method getGain (line 21) | public static double getGain(double sum, double weight) {
    method getProbability (line 35) | public static double getProbability(double pred) {
    method getResidual (line 46) | public static double getResidual(double pred, double target) {
    method getPseudoResidual (line 57) | public static double getPseudoResidual(double pred, double cls) {
    method computePseudoResidual (line 68) | public static void computePseudoResidual(double[] prediction, double[]...
    method computeProbabilities (line 80) | public static void computeProbabilities(double[] pred, double[] prob) {
    method computeLogisticLoss (line 93) | public static double computeLogisticLoss(double pred, double cls) {
    method computeLogisticLoss (line 108) | public static double computeLogisticLoss(double[] pred, double[] y) {
    method computeLogLoss (line 123) | public static double computeLogLoss(double prob, double y) {
    method computeLogLoss (line 135) | public static double computeLogLoss(double p, double y, boolean isRawS...
    method computeLogLoss (line 153) | public static double computeLogLoss(double[] prob, double[] y) {
    method computeLogLoss (line 165) | public static double computeLogLoss(double[] p, double[] y, boolean is...
    method computeQuadraticLoss (line 179) | public static double computeQuadraticLoss(double[] residual) {
    method fitIntercept (line 189) | public static double fitIntercept(double[] residual) {
    method fitIntercept (line 203) | public static double fitIntercept(double[] prediction, double[] residu...
    method isConverged (line 234) | public static boolean isConverged(double prevLoss, double currLoss, do...
    method isConverged (line 249) | public static boolean isConverged(double[] p, boolean isLargerBetter) {
    method isConverged (line 283) | public static boolean isConverged(List<Double> list, boolean isLargerB...

FILE: src/main/java/mltk/util/Permutation.java
  class Permutation (line 9) | public class Permutation {
    method Permutation (line 18) | public Permutation(int n) {
    method permute (line 30) | public Permutation permute() {
    method size (line 45) | public int size() {
    method getPermutation (line 54) | public int[] getPermutation() {

FILE: src/main/java/mltk/util/Queue.java
  class Queue (line 12) | public class Queue<T> {
    method Queue (line 19) | public Queue() {
    method enqueue (line 28) | public void enqueue(T item) {
    method dequeue (line 37) | public T dequeue() {
    method isEmpty (line 48) | public boolean isEmpty() {

FILE: src/main/java/mltk/util/Random.java
  class Random (line 9) | public class Random {
    method Random (line 14) | protected Random() {
    method getInstance (line 23) | public static Random getInstance() {
    method setSeed (line 35) | public void setSeed(long seed) {
    method nextInt (line 45) | public int nextInt() {
    method nextInt (line 56) | public int nextInt(int n) {
    method nextDouble (line 66) | public double nextDouble() {
    method nextFloat (line 76) | public float nextFloat() {
    method nextGaussian (line 86) | public double nextGaussian() {
    method nextLong (line 96) | public long nextLong() {
    method nextBoolean (line 106) | public boolean nextBoolean() {
    method nextBytes (line 115) | public void nextBytes(byte[] bytes) {
    method getRandom (line 124) | public java.util.Random getRandom() {

FILE: src/main/java/mltk/util/Stack.java
  class Stack (line 14) | public class Stack<T> {
    method Stack (line 21) | public Stack() {
    method push (line 30) | public void push(T item) {
    method peek (line 39) | public T peek() {
    method pop (line 51) | public T pop() {
    method isEmpty (line 62) | public boolean isEmpty() {

FILE: src/main/java/mltk/util/StatUtils.java
  class StatUtils (line 9) | public class StatUtils {
    method max (line 17) | public static int max(int[] a) {
    method max (line 33) | public static double max(double[] a) {
    method indexOfMax (line 49) | public static int indexOfMax(int[] a) {
    method indexOfMax (line 67) | public static int indexOfMax(double[] a) {
    method min (line 85) | public static int min(int[] a) {
    method min (line 101) | public static double min(double[] a) {
    method indexOfMin (line 117) | public static int indexOfMin(int[] a) {
    method indexOfMin (line 135) | public static int indexOfMin(double[] a) {
    method sum (line 153) | public static double sum(double[] a) {
    method sumSq (line 167) | public static double sumSq(double[] a) {
    method sumSq (line 179) | public static double sumSq(double[] a, int fromIndex, int toIndex) {
    method mean (line 193) | public static double mean(double[] a) {
    method mean (line 204) | public static double mean(double[] a, int n) {
    method variance (line 218) | public static double variance(double[] a) {
    method variance (line 229) | public static double variance(double[] a, int n) {
    method sd (line 245) | public static double sd(double[] a) {
    method sd (line 256) | public static double sd(double[] a, int n) {
    method rms (line 266) | public static double rms(double[] a) {
    method mad (line 282) | public static double mad(double[] a, double centralPoint) {

FILE: src/main/java/mltk/util/UFSets.java
  class UFSets (line 9) | public class UFSets {
    method UFSets (line 18) | public UFSets(int size) {
    method union (line 31) | public void union(int root1, int root2) {
    method find (line 48) | public int find(int i) {

FILE: src/main/java/mltk/util/VectorUtils.java
  class VectorUtils (line 13) | public class VectorUtils {
    method add (line 21) | public static void add(double[] a, double v) {
    method subtract (line 33) | public static void subtract(double[] a, double v) {
    method multiply (line 45) | public static void multiply(double[] a, double v) {
    method divide (line 57) | public static void divide(double[] a, double v) {
    method l2norm (line 69) | public static double l2norm(double[] a) {
    method l2norm (line 79) | public static double l2norm(Vector v) {
    method l1norm (line 89) | public static double l1norm(double[] a) {
    method l1norm (line 103) | public static double l1norm(Vector v) {
    method dotProduct (line 114) | public static double dotProduct(double[] a, double[] b) {
    method dotProduct (line 129) | public static double dotProduct(DenseVector a, DenseVector b) {
    method dotProduct (line 140) | public static double dotProduct(SparseVector a, DenseVector b) {
    method dotProduct (line 158) | public static double dotProduct(DenseVector a, SparseVector b) {
    method dotProduct (line 169) | public static double dotProduct(SparseVector a, SparseVector b) {
    method correlation (line 198) | public static double correlation(double[] a, double[] b) {

FILE: src/main/java/mltk/util/tuple/DoublePair.java
  class DoublePair (line 9) | public class DoublePair {
    method DoublePair (line 20) | public DoublePair(double v1, double v2) {
    method hashCode (line 25) | @Override
    method equals (line 37) | @Override

FILE: src/main/java/mltk/util/tuple/IntDoublePair.java
  class IntDoublePair (line 9) | public class IntDoublePair {
    method IntDoublePair (line 20) | public IntDoublePair(int v1, double v2) {
    method hashCode (line 25) | @Override
    method equals (line 36) | @Override

FILE: src/main/java/mltk/util/tuple/IntDoublePairComparator.java
  class IntDoublePairComparator (line 11) | public class IntDoublePairComparator implements Comparator<IntDoublePair> {
    method IntDoublePairComparator (line 16) | public IntDoublePairComparator() {
    method IntDoublePairComparator (line 20) | public IntDoublePairComparator(boolean firstIsKey) {
    method IntDoublePairComparator (line 24) | public IntDoublePairComparator(boolean firstIsKey, boolean ascending) {
    method compare (line 29) | @Override

FILE: src/main/java/mltk/util/tuple/IntPair.java
  class IntPair (line 9) | public class IntPair {
    method IntPair (line 20) | public IntPair(int v1, int v2) {
    method hashCode (line 25) | @Override
    method equals (line 34) | @Override

FILE: src/main/java/mltk/util/tuple/IntTriple.java
  class IntTriple (line 9) | public class IntTriple {
    method IntTriple (line 22) | public IntTriple(int v1, int v2, int v3) {
    method hashCode (line 28) | @Override
    method equals (line 38) | @Override

FILE: src/main/java/mltk/util/tuple/LongDoublePair.java
  class LongDoublePair (line 9) | public class LongDoublePair {
    method LongDoublePair (line 20) | public LongDoublePair(long v1, double v2) {
    method hashCode (line 25) | @Override
    method equals (line 36) | @Override
    method toString (line 52) | @Override

FILE: src/main/java/mltk/util/tuple/LongDoublePairComparator.java
  class LongDoublePairComparator (line 11) | public class LongDoublePairComparator implements Comparator<LongDoublePa...
    method LongDoublePairComparator (line 16) | public LongDoublePairComparator() {
    method LongDoublePairComparator (line 20) | public LongDoublePairComparator(boolean firstIsKey) {
    method LongDoublePairComparator (line 24) | public LongDoublePairComparator(boolean firstIsKey, boolean ascending) {
    method compare (line 29) | @Override

FILE: src/main/java/mltk/util/tuple/LongPair.java
  class LongPair (line 9) | public class LongPair {
    method LongPair (line 20) | public LongPair(long v1, long v2) {
    method hashCode (line 25) | @Override
    method equals (line 34) | @Override

FILE: src/main/java/mltk/util/tuple/Pair.java
  class Pair (line 11) | public class Pair<T1, T2> {
    method Pair (line 22) | public Pair(T1 v1, T2 v2) {
    method hashCode (line 27) | @Override
    method equals (line 36) | @Override

FILE: src/main/java/mltk/util/tuple/Triple.java
  class Triple (line 12) | public class Triple<T1, T2, T3> {
    method Triple (line 25) | public Triple(T1 v1, T2 v2, T3 v3) {
    method hashCode (line 31) | @Override
    method equals (line 41) | @Override

FILE: src/test/java/mltk/core/BinsTest.java
  class BinsTest (line 8) | public class BinsTest {
    method testBins (line 10) | @Test

FILE: src/test/java/mltk/core/InstancesTestHelper.java
  class InstancesTestHelper (line 6) | public class InstancesTestHelper {
    method getInstance (line 15) | public static InstancesTestHelper getInstance() {
    method getDenseClassificationDataset (line 22) | public Instances getDenseClassificationDataset() {
    method getDenseRegressionDataset (line 26) | public Instances getDenseRegressionDataset() {
    method getDenseClassificationDatasetWMissing (line 30) | public Instances getDenseClassificationDatasetWMissing() {
    method getDenseRegressionDatasetWMissing (line 34) | public Instances getDenseRegressionDatasetWMissing() {
    method InstancesTestHelper (line 38) | private InstancesTestHelper() {

FILE: src/test/java/mltk/core/io/AttributesReaderTest.java
  class AttributesReaderTest (line 20) | public class AttributesReaderTest {
    method testIO (line 22) | @Test

FILE: src/test/java/mltk/core/io/InstancesReaderTest.java
  class InstancesReaderTest (line 8) | public class InstancesReaderTest {
    method testDenseFormat (line 10) | @Test

FILE: src/test/java/mltk/core/processor/DiscretizerTest.java
  class DiscretizerTest (line 11) | public class DiscretizerTest {
    method testMissingValue (line 13) | @Test

FILE: src/test/java/mltk/core/processor/InstancesSplitterTest.java
  class InstancesSplitterTest (line 11) | public class InstancesSplitterTest {
    method testSamplingTrainValid (line 13) | @Test
    method testSamplingTrainValidTest (line 25) | @Test
    method testStratifiedSampling (line 39) | @Test

FILE: src/test/java/mltk/predictor/evaluation/AUCTest.java
  class AUCTest (line 8) | public class AUCTest {
    method test1 (line 10) | @Test
    method test2 (line 18) | @Test

FILE: src/test/java/mltk/predictor/evaluation/ConvergenceTesterTest.java
  class ConvergenceTesterTest (line 6) | public class ConvergenceTesterTest {
    method test1 (line 8) | @Test
    method test2 (line 26) | @Test
    method test3 (line 44) | @Test
    method test4 (line 62) | @Test
    method testParse (line 80) | @Test

FILE: src/test/java/mltk/predictor/evaluation/ErrorTest.java
  class ErrorTest (line 8) | public class ErrorTest {
    method testLabel (line 10) | @Test
    method testProbability (line 18) | @Test

FILE: src/test/java/mltk/predictor/evaluation/LogLossTest.java
  class LogLossTest (line 8) | public class LogLossTest {
    method testProb (line 10) | @Test
    method testRawScore (line 18) | @Test

FILE: src/test/java/mltk/predictor/evaluation/LogisticLossTest.java
  class LogisticLossTest (line 8) | public class LogisticLossTest {
    method test (line 10) | @Test

FILE: src/test/java/mltk/predictor/evaluation/MAETest.java
  class MAETest (line 8) | public class MAETest {
    method test (line 10) | @Test

FILE: src/test/java/mltk/predictor/evaluation/MetricFactoryTest.java
  class MetricFactoryTest (line 6) | public class MetricFactoryTest {
    method test (line 8) | @Test

FILE: src/test/java/mltk/predictor/evaluation/RMSETest.java
  class RMSETest (line 8) | public class RMSETest {
    method test (line 10) | @Test

FILE: src/test/java/mltk/predictor/glm/GLMTest.java
  class GLMTest (line 15) | public class GLMTest {
    method testIO (line 17) | @Test

FILE: src/test/java/mltk/predictor/tree/DecisionTableLearnerTest.java
  class DecisionTableLearnerTest (line 12) | public class DecisionTableLearnerTest {
    method testDecisionTableLearner1 (line 14) | @Test
    method testDecisionTableLearner2 (line 27) | @Test

FILE: src/test/java/mltk/predictor/tree/DecisionTableTest.java
  class DecisionTableTest (line 17) | public class DecisionTableTest {
    method testIO (line 19) | @Test
    method testRegress (line 42) | @Test

FILE: src/test/java/mltk/predictor/tree/DecisionTableTestHelper.java
  class DecisionTableTestHelper (line 3) | public class DecisionTableTestHelper {
    method getInstance (line 10) | public static DecisionTableTestHelper getInstance() {
    method getTable1 (line 17) | public DecisionTable getTable1() {
    method getTable2 (line 21) | public DecisionTable getTable2() {
    method DecisionTableTestHelper (line 25) | private DecisionTableTestHelper() {
    method buildDecisionTable1 (line 30) | private void buildDecisionTable1() {
    method buildDecisionTable2 (line 39) | private void buildDecisionTable2() {

FILE: src/test/java/mltk/predictor/tree/RegressionTreeLearnerTest.java
  class RegressionTreeLearnerTest (line 12) | public class RegressionTreeLearnerTest {
    method testRegressionTreeLearner1 (line 14) | @Test
    method testRegressionTreeLearner2 (line 28) | @Test

FILE: src/test/java/mltk/predictor/tree/RegressionTreeTest.java
  class RegressionTreeTest (line 15) | public class RegressionTreeTest {
    method testIO (line 17) | @Test

FILE: src/test/java/mltk/predictor/tree/RegressionTreeTestHelper.java
  class RegressionTreeTestHelper (line 3) | public class RegressionTreeTestHelper {
    method getInstance (line 10) | public static RegressionTreeTestHelper getInstance() {
    method getTree1 (line 17) | public RegressionTree getTree1() {
    method getTree2 (line 21) | public RegressionTree getTree2() {
    method RegressionTreeTestHelper (line 25) | private RegressionTreeTestHelper() {
    method buildTree1 (line 30) | private void buildTree1() {
    method buildTree2 (line 44) | private void buildTree2() {

FILE: src/test/java/mltk/predictor/tree/ensemble/BoostedDTablesTest.java
  class BoostedDTablesTest (line 16) | public class BoostedDTablesTest {
    method testIO (line 18) | @Test

FILE: src/test/java/mltk/predictor/tree/ensemble/BoostedRTreesTest.java
  class BoostedRTreesTest (line 18) | public class BoostedRTreesTest {
    method testIO (line 20) | @Test

FILE: src/test/java/mltk/predictor/tree/ensemble/brt/BDTTest.java
  class BDTTest (line 22) | public class BDTTest {
    method BDTTest (line 26) | public BDTTest() {
    method testIO (line 37) | @Test
    method testRegress (line 67) | @Test

FILE: src/test/java/mltk/predictor/tree/ensemble/brt/BRTTest.java
  class BRTTest (line 20) | public class BRTTest {
    method testIO (line 22) | @Test

FILE: src/test/java/mltk/predictor/tree/ensemble/brt/BRTUtilsTest.java
  class BRTUtilsTest (line 10) | public class BRTUtilsTest {
    method testParseRegressionTreeLearner1 (line 12) | @Test
    method testParseRegressionTreeLearner2 (line 23) | @Test
    method testParseRegressionTreeLearner3 (line 34) | @Test
    method testParseRegressionTreeLearner4 (line 45) | @Test
    method testParseRobustRegressionTreeLearner1 (line 56) | @Test
    method testParseRobustRegressionTreeLearner2 (line 67) | @Test
    method testParseRobustRegressionTreeLearner3 (line 78) | @Test
    method testParseRobustRegressionTreeLearner4 (line 89) | @Test

FILE: src/test/java/mltk/predictor/tree/ensemble/brt/LogitBoostLearnerTest.java
  class LogitBoostLearnerTest (line 12) | public class LogitBoostLearnerTest {
    method testLogitBoostLearner (line 14) | @Test

FILE: src/test/java/mltk/util/ArrayUtilsTest.java
  class ArrayUtilsTest (line 6) | public class ArrayUtilsTest {
    method testParseDoubleArray (line 8) | @Test
    method testParseIntArray (line 15) | @Test
    method testIsConstant (line 22) | @Test
    method testGetMedian (line 37) | @Test

FILE: src/test/java/mltk/util/MathUtilsTest.java
  class MathUtilsTest (line 6) | public class MathUtilsTest {
    method testEquals (line 8) | @Test
    method testIndicator (line 14) | @Test
    method testIsFirstBetter (line 20) | @Test
    method testIsInteger (line 26) | @Test
    method testIsZero (line 32) | @Test
    method testSigmoid (line 38) | @Test
    method testSign (line 43) | @Test

FILE: src/test/java/mltk/util/OptimUtilsTest.java
  class OptimUtilsTest (line 6) | public class OptimUtilsTest {
    method testGetProbability (line 8) | @Test
    method testGetResidual (line 13) | @Test
    method testGetPseudoResidual (line 18) | @Test
    method testComputeLogisticLoss (line 24) | @Test
    method testIsConverged (line 32) | @Test

FILE: src/test/java/mltk/util/StatUtilsTest.java
  class StatUtilsTest (line 6) | public class StatUtilsTest {
    method testMax (line 11) | @Test
    method testIndexOfMax (line 17) | @Test
    method testMin (line 23) | @Test
    method testIndexOfMin (line 29) | @Test
    method testSum (line 35) | @Test
    method testSumSq (line 40) | @Test
    method testMean (line 46) | @Test
    method testVariance (line 51) | @Test
    method testStd (line 56) | @Test
    method testRms (line 61) | @Test

FILE: src/test/java/mltk/util/VectorUtilsTest.java
  class VectorUtilsTest (line 6) | public class VectorUtilsTest {
    method testAdd (line 8) | @Test
    method testSubtract (line 16) | @Test
    method testMultiply (line 24) | @Test
    method testDivide (line 32) | @Test
    method testL2norm (line 40) | @Test
    method testL1norm (line 46) | @Test
    method testDotProduct (line 52) | @Test
    method testCorrelation (line 59) | @Test
Condensed preview — 194 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (944K chars).
[
  {
    "path": ".gitignore",
    "chars": 227,
    "preview": "*~\n*.swp\n\n*.class\n\n# osx\n.DS_Store\n\n# Eclipse build artifacts\n.project\n.classpath\n\n# Maven\ntarget\n\nbuild/\n**/build/\nclas"
  },
  {
    "path": "LICENSE",
    "chars": 1510,
    "preview": "Copyright (c) 2012-2019, Yin Lou\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or withou"
  },
  {
    "path": "README.md",
    "chars": 424,
    "preview": "# Machine Learning Tool Kit\n\nMLTK is a collection of various supervised machine learning algorithms, which is designed f"
  },
  {
    "path": "pom.xml",
    "chars": 4306,
    "preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2"
  },
  {
    "path": "src/main/java/mltk/cmdline/Argument.java",
    "chars": 700,
    "preview": "package mltk.cmdline;\n\nimport java.lang.annotation.ElementType;\nimport java.lang.annotation.Retention;\nimport java.lang."
  },
  {
    "path": "src/main/java/mltk/cmdline/CmdLineParser.java",
    "chars": 3112,
    "preview": "package mltk.cmdline;\r\n\r\nimport java.lang.reflect.Field;\r\nimport java.util.ArrayList;\r\nimport java.util.HashMap;\r\nimport"
  },
  {
    "path": "src/main/java/mltk/cmdline/options/HoldoutValidatedLearnerOptions.java",
    "chars": 454,
    "preview": "package mltk.cmdline.options;\n\nimport mltk.cmdline.Argument;\n\npublic class HoldoutValidatedLearnerOptions extends Learne"
  },
  {
    "path": "src/main/java/mltk/cmdline/options/HoldoutValidatedLearnerWithTaskOptions.java",
    "chars": 292,
    "preview": "package mltk.cmdline.options;\n\nimport mltk.cmdline.Argument;\n\npublic class HoldoutValidatedLearnerWithTaskOptions extend"
  },
  {
    "path": "src/main/java/mltk/cmdline/options/LearnerOptions.java",
    "chars": 494,
    "preview": "package mltk.cmdline.options;\n\nimport mltk.cmdline.Argument;\n\npublic class LearnerOptions {\n\n\t@Argument(name = \"-r\", des"
  },
  {
    "path": "src/main/java/mltk/cmdline/options/LearnerWithTaskOptions.java",
    "chars": 260,
    "preview": "package mltk.cmdline.options;\n\nimport mltk.cmdline.Argument;\n\npublic class LearnerWithTaskOptions extends LearnerOptions"
  },
  {
    "path": "src/main/java/mltk/cmdline/options/package-info.java",
    "chars": 86,
    "preview": "/**\n * Provides classes for command line options.\n *\n */\npackage mltk.cmdline.options;"
  },
  {
    "path": "src/main/java/mltk/cmdline/package-info.java",
    "chars": 74,
    "preview": "/**\n * Provides classes for command line parser.\n */\npackage mltk.cmdline;"
  },
  {
    "path": "src/main/java/mltk/core/Attribute.java",
    "chars": 1847,
    "preview": "package mltk.core;\n\n/**\n * Abstract class for attributes.\n * \n * @author Yin Lou\n * \n */\npublic abstract class Attribute"
  },
  {
    "path": "src/main/java/mltk/core/BinnedAttribute.java",
    "chars": 2816,
    "preview": "package mltk.core;\r\n\r\nimport java.util.Arrays;\r\n\r\nimport mltk.util.ArrayUtils;\r\n\r\n/**\r\n * Class for discretized attribut"
  },
  {
    "path": "src/main/java/mltk/core/Bins.java",
    "chars": 1863,
    "preview": "package mltk.core;\r\n\r\nimport mltk.util.ArrayUtils;\r\n\r\n/**\r\n * Class for bins. Each bin is defined as its upper bound and"
  },
  {
    "path": "src/main/java/mltk/core/Copyable.java",
    "chars": 266,
    "preview": "package mltk.core;\n\n/**\n * Copyable interface.\n * \n * @author Yin Lou\n * \n * @param <T> the type of the object.\n */\npubl"
  },
  {
    "path": "src/main/java/mltk/core/DenseVector.java",
    "chars": 1208,
    "preview": "package mltk.core;\r\n\r\nimport java.util.Arrays;\r\n\r\n/**\r\n * Class for dense vectors.\r\n * \r\n * @author Yin Lou\r\n * \r\n */\r\np"
  },
  {
    "path": "src/main/java/mltk/core/Instance.java",
    "chars": 6760,
    "preview": "package mltk.core;\n\nimport mltk.util.MathUtils;\n\n/**\n * Class for instances.\n * \n * @author Yin Lou\n * \n */\npublic class"
  },
  {
    "path": "src/main/java/mltk/core/Instances.java",
    "chars": 4440,
    "preview": "package mltk.core;\n\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.Iterator;\nimport java.uti"
  },
  {
    "path": "src/main/java/mltk/core/NominalAttribute.java",
    "chars": 2072,
    "preview": "package mltk.core;\n\n/**\n * Class for nominal attributes.\n * \n * @author Yin Lou\n * \n */\npublic class NominalAttribute ex"
  },
  {
    "path": "src/main/java/mltk/core/NumericalAttribute.java",
    "chars": 1011,
    "preview": "package mltk.core;\n\n/**\n * Class for numerical attributes.\n * \n * @author Yin Lou\n * \n */\npublic class NumericalAttribut"
  },
  {
    "path": "src/main/java/mltk/core/Sampling.java",
    "chars": 3387,
    "preview": "package mltk.core;\n\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\n\nimport mltk.util.Permutation"
  },
  {
    "path": "src/main/java/mltk/core/SparseVector.java",
    "chars": 1814,
    "preview": "package mltk.core;\r\n\r\nimport java.util.Arrays;\r\n\r\n/**\r\n * Class for sparse vectors.\r\n * \r\n * @author Yin Lou\r\n * \r\n */\r\n"
  },
  {
    "path": "src/main/java/mltk/core/Vector.java",
    "chars": 1284,
    "preview": "package mltk.core;\n\n/**\n * Interface for vectors.\n * \n * @author Yin Lou\n * \n */\npublic interface Vector extends Copyabl"
  },
  {
    "path": "src/main/java/mltk/core/Writable.java",
    "chars": 443,
    "preview": "package mltk.core;\n\nimport java.io.BufferedReader;\nimport java.io.PrintWriter;\n\n/**\n * Writable interface.\n * \n * @autho"
  },
  {
    "path": "src/main/java/mltk/core/io/AttributesReader.java",
    "chars": 2233,
    "preview": "package mltk.core.io;\n\nimport java.io.BufferedReader;\nimport java.io.FileReader;\nimport java.io.IOException;\nimport java"
  },
  {
    "path": "src/main/java/mltk/core/io/InstancesReader.java",
    "chars": 8865,
    "preview": "package mltk.core.io;\r\n\r\nimport java.io.BufferedReader;\r\nimport java.io.FileReader;\r\nimport java.io.IOException;\r\nimport"
  },
  {
    "path": "src/main/java/mltk/core/io/InstancesWriter.java",
    "chars": 1347,
    "preview": "package mltk.core.io;\n\nimport java.io.IOException;\nimport java.io.PrintWriter;\nimport java.util.List;\n\nimport mltk.core."
  },
  {
    "path": "src/main/java/mltk/core/io/package-info.java",
    "chars": 83,
    "preview": "/**\n * Contains classes for reading and writing datasets.\n */\npackage mltk.core.io;"
  },
  {
    "path": "src/main/java/mltk/core/package-info.java",
    "chars": 99,
    "preview": "/**\n * Provides classes and interfaces for handling datasets and attributes.\n */\npackage mltk.core;"
  },
  {
    "path": "src/main/java/mltk/core/processor/Discretizer.java",
    "chars": 8863,
    "preview": "package mltk.core.processor;\r\n\r\nimport java.util.ArrayList;\r\nimport java.util.Collections;\r\nimport java.util.List;\r\n\r\nim"
  },
  {
    "path": "src/main/java/mltk/core/processor/InstancesSplitter.java",
    "chars": 17324,
    "preview": "package mltk.core.processor;\r\n\r\nimport java.io.File;\r\nimport java.util.ArrayList;\r\nimport java.util.List;\r\n\r\nimport mltk"
  },
  {
    "path": "src/main/java/mltk/core/processor/OneHotEncoder.java",
    "chars": 2713,
    "preview": "package mltk.core.processor;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport mltk.core.Attribute;\nimport mlt"
  },
  {
    "path": "src/main/java/mltk/core/processor/package-info.java",
    "chars": 81,
    "preview": "/**\n * Provides classes for processing datasets.\n */\npackage mltk.core.processor;"
  },
  {
    "path": "src/main/java/mltk/feature/selection/BackwardElimination.java",
    "chars": 5572,
    "preview": "package mltk.feature.selection;\r\n\r\nimport java.util.ArrayList;\r\nimport java.util.List;\r\n\r\nimport mltk.core.Attribute;\r\ni"
  },
  {
    "path": "src/main/java/mltk/feature/selection/package-info.java",
    "chars": 85,
    "preview": "/**\r\n * Contains classes for feature selection.\r\n */\r\npackage mltk.feature.selection;"
  },
  {
    "path": "src/main/java/mltk/predictor/BaggedEnsemble.java",
    "chars": 1747,
    "preview": "package mltk.predictor;\r\n\r\nimport java.util.HashMap;\r\nimport java.util.Map;\r\n\r\nimport mltk.core.Instance;\r\n\r\n/**\r\n * Cla"
  },
  {
    "path": "src/main/java/mltk/predictor/BaggedEnsembleLearner.java",
    "chars": 2239,
    "preview": "package mltk.predictor;\r\n\r\nimport mltk.core.Instances;\r\nimport mltk.core.Sampling;\r\n\r\n/**\r\n * Class for learning bagged "
  },
  {
    "path": "src/main/java/mltk/predictor/BoostedEnsemble.java",
    "chars": 1402,
    "preview": "package mltk.predictor;\r\n\r\nimport mltk.core.Instance;\r\n\r\n/**\r\n * Class for boosted ensembles.\r\n * \r\n * @author Yin Lou\r\n"
  },
  {
    "path": "src/main/java/mltk/predictor/Classifier.java",
    "chars": 352,
    "preview": "package mltk.predictor;\r\n\r\nimport mltk.core.Instance;\r\n\r\n/**\r\n * Interface for classfiers.\r\n * \r\n * @author Yin Lou\r\n * "
  },
  {
    "path": "src/main/java/mltk/predictor/Ensemble.java",
    "chars": 2272,
    "preview": "package mltk.predictor;\r\n\r\nimport java.io.BufferedReader;\r\nimport java.io.PrintWriter;\r\nimport java.util.ArrayList;\r\nimp"
  },
  {
    "path": "src/main/java/mltk/predictor/Family.java",
    "chars": 1070,
    "preview": "package mltk.predictor;\n\n/**\n * Class for response distribution family. This class is used for GLMs/GAMs.\n * \n * @author"
  },
  {
    "path": "src/main/java/mltk/predictor/HoldoutValidatedLearner.java",
    "chars": 1368,
    "preview": "package mltk.predictor;\n\nimport mltk.core.Instances;\nimport mltk.predictor.evaluation.ConvergenceTester;\nimport mltk.pre"
  },
  {
    "path": "src/main/java/mltk/predictor/Learner.java",
    "chars": 8571,
    "preview": "package mltk.predictor;\n\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.TreeM"
  },
  {
    "path": "src/main/java/mltk/predictor/LinkFunction.java",
    "chars": 1103,
    "preview": "package mltk.predictor;\n\nimport mltk.util.MathUtils;\n\n/**\n * Class for link functions.\n * \n * @author Yin Lou\n *\n */\npub"
  },
  {
    "path": "src/main/java/mltk/predictor/Predictor.java",
    "chars": 701,
    "preview": "package mltk.predictor;\n\nimport java.io.BufferedReader;\nimport java.io.PrintWriter;\n\nimport mltk.core.Copyable;\nimport m"
  },
  {
    "path": "src/main/java/mltk/predictor/ProbabilisticClassifier.java",
    "chars": 435,
    "preview": "package mltk.predictor;\r\n\r\nimport mltk.core.Instance;\r\n\r\n/**\r\n * Interface for classifiers that predicts the class proba"
  },
  {
    "path": "src/main/java/mltk/predictor/Regressor.java",
    "chars": 350,
    "preview": "package mltk.predictor;\r\n\r\nimport mltk.core.Instance;\r\n\r\n/**\r\n * Interface for regressors.\r\n * \r\n * @author Yin Lou\r\n * "
  },
  {
    "path": "src/main/java/mltk/predictor/evaluation/AUC.java",
    "chars": 2060,
    "preview": "package mltk.predictor.evaluation;\n\nimport java.util.Arrays;\nimport java.util.Comparator;\n\nimport mltk.core.Instances;\ni"
  },
  {
    "path": "src/main/java/mltk/predictor/evaluation/ConvergenceTester.java",
    "chars": 4067,
    "preview": "package mltk.predictor.evaluation;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\n/**\n * Class for testing converg"
  },
  {
    "path": "src/main/java/mltk/predictor/evaluation/Error.java",
    "chars": 876,
    "preview": "package mltk.predictor.evaluation;\n\nimport mltk.core.Instances;\n\n/**\n * Class for evaluating error rate.\n * \n * @author "
  },
  {
    "path": "src/main/java/mltk/predictor/evaluation/Evaluator.java",
    "chars": 5618,
    "preview": "package mltk.predictor.evaluation;\n\nimport java.util.List;\n\nimport mltk.cmdline.Argument;\nimport mltk.cmdline.CmdLinePar"
  },
  {
    "path": "src/main/java/mltk/predictor/evaluation/LogLoss.java",
    "chars": 1125,
    "preview": "package mltk.predictor.evaluation;\n\nimport mltk.core.Instances;\nimport mltk.util.OptimUtils;\n\n/**\n * Class for evaluatin"
  },
  {
    "path": "src/main/java/mltk/predictor/evaluation/LogisticLoss.java",
    "chars": 713,
    "preview": "package mltk.predictor.evaluation;\n\nimport mltk.core.Instances;\nimport mltk.util.OptimUtils;\n\n/**\n * Class for evaluatin"
  },
  {
    "path": "src/main/java/mltk/predictor/evaluation/MAE.java",
    "chars": 709,
    "preview": "package mltk.predictor.evaluation;\n\nimport mltk.core.Instances;\n\n/**\n * Class for evaluating mean absolute error (MAE).\n"
  },
  {
    "path": "src/main/java/mltk/predictor/evaluation/Metric.java",
    "chars": 1858,
    "preview": "package mltk.predictor.evaluation;\n\nimport java.util.List;\n\nimport mltk.core.Instances;\nimport mltk.util.MathUtils;\n\n/**"
  },
  {
    "path": "src/main/java/mltk/predictor/evaluation/MetricFactory.java",
    "chars": 1176,
    "preview": "package mltk.predictor.evaluation;\n\nimport java.util.HashMap;\nimport java.util.Map;\n\n/**\n * Factory class for creating m"
  },
  {
    "path": "src/main/java/mltk/predictor/evaluation/Predictor.java",
    "chars": 5688,
    "preview": "package mltk.predictor.evaluation;\n\nimport java.io.IOException;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\n\nim"
  },
  {
    "path": "src/main/java/mltk/predictor/evaluation/RMSE.java",
    "chars": 780,
    "preview": "package mltk.predictor.evaluation;\n\nimport mltk.core.Instances;\n\n/**\n * Class for evaluating root mean squared error (RM"
  },
  {
    "path": "src/main/java/mltk/predictor/evaluation/SimpleMetric.java",
    "chars": 552,
    "preview": "package mltk.predictor.evaluation;\n\n/**\n * Class for simple metrics.\n * \n * @author Yin Lou\n *\n */\npublic abstract class"
  },
  {
    "path": "src/main/java/mltk/predictor/evaluation/package-info.java",
    "chars": 92,
    "preview": "/**\r\n * Provides classes for evaluating predictors.\r\n */\r\npackage mltk.predictor.evaluation;"
  },
  {
    "path": "src/main/java/mltk/predictor/function/Array1D.java",
    "chars": 4071,
    "preview": "package mltk.predictor.function;\n\nimport java.io.BufferedReader;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\n\ni"
  },
  {
    "path": "src/main/java/mltk/predictor/function/Array2D.java",
    "chars": 8053,
    "preview": "package mltk.predictor.function;\n\nimport java.io.BufferedReader;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\n\ni"
  },
  {
    "path": "src/main/java/mltk/predictor/function/BaggedLineCutter.java",
    "chars": 4968,
    "preview": "package mltk.predictor.function;\n\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\n\nimpo"
  },
  {
    "path": "src/main/java/mltk/predictor/function/BivariateFunction.java",
    "chars": 356,
    "preview": "package mltk.predictor.function;\n\n/**\n * Interface for bivariate real functions.\n * \n * @author Yin Lou\n * \n */\npublic i"
  },
  {
    "path": "src/main/java/mltk/predictor/function/CHistogram.java",
    "chars": 832,
    "preview": "package mltk.predictor.function;\r\n\r\n/**\r\n * Class for cumulative histograms.\r\n * \r\n * @author Yin Lou\r\n * \r\n */\r\npublic "
  },
  {
    "path": "src/main/java/mltk/predictor/function/CompressionUtils.java",
    "chars": 6381,
    "preview": "package mltk.predictor.function;\n\nimport mltk.core.Instance;\nimport mltk.predictor.BaggedEnsemble;\nimport mltk.predictor"
  },
  {
    "path": "src/main/java/mltk/predictor/function/CubicSpline.java",
    "chars": 3747,
    "preview": "package mltk.predictor.function;\n\nimport java.io.BufferedReader;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\n\ni"
  },
  {
    "path": "src/main/java/mltk/predictor/function/EnsembledLineCutter.java",
    "chars": 2561,
    "preview": "package mltk.predictor.function;\n\nimport mltk.core.Attribute;\nimport mltk.core.Instances;\nimport mltk.predictor.BaggedEn"
  },
  {
    "path": "src/main/java/mltk/predictor/function/Function1D.java",
    "chars": 8265,
    "preview": "package mltk.predictor.function;\n\nimport java.io.BufferedReader;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\n\ni"
  },
  {
    "path": "src/main/java/mltk/predictor/function/Function2D.java",
    "chars": 14414,
    "preview": "package mltk.predictor.function;\r\n\r\nimport java.io.BufferedReader;\r\nimport java.io.PrintWriter;\r\nimport java.util.Arrays"
  },
  {
    "path": "src/main/java/mltk/predictor/function/Histogram2D.java",
    "chars": 6385,
    "preview": "package mltk.predictor.function;\r\n\r\nimport mltk.core.Instance;\r\nimport mltk.core.Instances;\r\nimport mltk.util.tuple.Pair"
  },
  {
    "path": "src/main/java/mltk/predictor/function/LineCutter.java",
    "chars": 12109,
    "preview": "package mltk.predictor.function;\n\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.List;\nimpor"
  },
  {
    "path": "src/main/java/mltk/predictor/function/LinearFunction.java",
    "chars": 1829,
    "preview": "package mltk.predictor.function;\r\n\r\nimport java.io.BufferedReader;\r\nimport java.io.PrintWriter;\r\n\r\nimport mltk.core.Inst"
  },
  {
    "path": "src/main/java/mltk/predictor/function/SquareCutter.java",
    "chars": 23960,
    "preview": "package mltk.predictor.function;\n\nimport java.util.List;\n\nimport mltk.core.Attribute;\nimport mltk.core.BinnedAttribute;\n"
  },
  {
    "path": "src/main/java/mltk/predictor/function/SubagSequence.java",
    "chars": 4264,
    "preview": "package mltk.predictor.function;\n\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.HashSet;\nimport"
  },
  {
    "path": "src/main/java/mltk/predictor/function/SubaggedLineCutter.java",
    "chars": 6494,
    "preview": "package mltk.predictor.function;\n\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\n\nimport ml"
  },
  {
    "path": "src/main/java/mltk/predictor/function/UnivariateFunction.java",
    "chars": 308,
    "preview": "package mltk.predictor.function;\n\n/**\n * Interface for univariate functions.\n * \n * @author Yin Lou\n * \n */\npublic inter"
  },
  {
    "path": "src/main/java/mltk/predictor/function/package-info.java",
    "chars": 122,
    "preview": "/**\n * Provides classes for simple functions, such as univariate/bivariate functions.\n */\npackage mltk.predictor.functio"
  },
  {
    "path": "src/main/java/mltk/predictor/gam/DenseDesignMatrix.java",
    "chars": 2344,
    "preview": "package mltk.predictor.gam;\r\n\r\nimport java.util.HashSet;\r\nimport java.util.Set;\r\n\r\nimport mltk.predictor.function.CubicS"
  },
  {
    "path": "src/main/java/mltk/predictor/gam/GA2MLearner.java",
    "chars": 25039,
    "preview": "package mltk.predictor.gam;\n\nimport java.io.BufferedReader;\nimport java.io.FileReader;\nimport java.util.ArrayList;\nimpor"
  },
  {
    "path": "src/main/java/mltk/predictor/gam/GAM.java",
    "chars": 4001,
    "preview": "package mltk.predictor.gam;\n\nimport java.io.BufferedReader;\nimport java.io.PrintWriter;\nimport java.util.ArrayList;\nimpo"
  },
  {
    "path": "src/main/java/mltk/predictor/gam/GAMLearner.java",
    "chars": 24027,
    "preview": "package mltk.predictor.gam;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport mltk.cmdline.Argument;\nimport ml"
  },
  {
    "path": "src/main/java/mltk/predictor/gam/GAMUtils.java",
    "chars": 1579,
    "preview": "package mltk.predictor.gam;\n\nimport java.util.List;\n\nimport mltk.core.Attribute;\nimport mltk.core.BinnedAttribute;\nimpor"
  },
  {
    "path": "src/main/java/mltk/predictor/gam/SPLAMLearner.java",
    "chars": 49543,
    "preview": "package mltk.predictor.gam;\n\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.HashMap;\nimport java."
  },
  {
    "path": "src/main/java/mltk/predictor/gam/ScorecardModelLearner.java",
    "chars": 5103,
    "preview": "package mltk.predictor.gam;\n\nimport mltk.cmdline.Argument;\nimport mltk.cmdline.CmdLineParser;\nimport mltk.cmdline.option"
  },
  {
    "path": "src/main/java/mltk/predictor/gam/SparseDesignMatrix.java",
    "chars": 2597,
    "preview": "package mltk.predictor.gam;\r\n\r\nimport java.util.HashSet;\r\nimport java.util.Set;\r\n\r\nimport mltk.predictor.function.CubicS"
  },
  {
    "path": "src/main/java/mltk/predictor/gam/interaction/FAST.java",
    "chars": 10057,
    "preview": "package mltk.predictor.gam.interaction;\r\n\r\nimport java.io.BufferedReader;\r\nimport java.io.FileReader;\r\nimport java.io.Pr"
  },
  {
    "path": "src/main/java/mltk/predictor/gam/interaction/package-info.java",
    "chars": 105,
    "preview": "/**\n * Provides algorithms for feature interaction detection.\n */\npackage mltk.predictor.gam.interaction;"
  },
  {
    "path": "src/main/java/mltk/predictor/gam/package-info.java",
    "chars": 106,
    "preview": "/**\n * Provides algorithms for fitting generalized additive models (GAMs).\n */\npackage mltk.predictor.gam;"
  },
  {
    "path": "src/main/java/mltk/predictor/gam/tool/Diagnostics.java",
    "chars": 4615,
    "preview": "package mltk.predictor.gam.tool;\n\nimport java.io.PrintWriter;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimpor"
  },
  {
    "path": "src/main/java/mltk/predictor/gam/tool/Visualizer.java",
    "chars": 17230,
    "preview": "package mltk.predictor.gam.tool;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.io.PrintWriter;\nimport ja"
  },
  {
    "path": "src/main/java/mltk/predictor/gam/tool/package-info.java",
    "chars": 95,
    "preview": "/**\n * Provides tools for diagnosing and visualizing GAMs.\n */\npackage mltk.predictor.gam.tool;"
  },
  {
    "path": "src/main/java/mltk/predictor/glm/ElasticNetLearner.java",
    "chars": 39370,
    "preview": "package mltk.predictor.glm;\n\nimport java.util.Arrays;\n\nimport mltk.cmdline.Argument;\nimport mltk.cmdline.CmdLineParser;\n"
  },
  {
    "path": "src/main/java/mltk/predictor/glm/GLM.java",
    "chars": 5606,
    "preview": "package mltk.predictor.glm;\n\nimport java.io.BufferedReader;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\n\nimport"
  },
  {
    "path": "src/main/java/mltk/predictor/glm/GLMLearner.java",
    "chars": 2344,
    "preview": "package mltk.predictor.glm;\n\nimport mltk.core.Instances;\nimport mltk.predictor.Family;\nimport mltk.predictor.Learner;\nim"
  },
  {
    "path": "src/main/java/mltk/predictor/glm/GLMOptimUtils.java",
    "chars": 2422,
    "preview": "package mltk.predictor.glm;\r\n\r\nimport mltk.predictor.LinkFunction;\r\nimport mltk.util.OptimUtils;\r\nimport mltk.util.StatU"
  },
  {
    "path": "src/main/java/mltk/predictor/glm/GroupLassoLearner.java",
    "chars": 62365,
    "preview": "package mltk.predictor.glm;\n\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.HashMap;\nimport java."
  },
  {
    "path": "src/main/java/mltk/predictor/glm/LassoLearner.java",
    "chars": 46260,
    "preview": "package mltk.predictor.glm;\n\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.HashSet;\nimport java."
  },
  {
    "path": "src/main/java/mltk/predictor/glm/RidgeLearner.java",
    "chars": 31571,
    "preview": "package mltk.predictor.glm;\n\nimport java.util.Arrays;\n\nimport mltk.cmdline.Argument;\nimport mltk.cmdline.CmdLineParser;\n"
  },
  {
    "path": "src/main/java/mltk/predictor/glm/package-info.java",
    "chars": 104,
    "preview": "/**\n * Provides algorithms for fitting generalized linear models (GLMs).\n */\npackage mltk.predictor.glm;"
  },
  {
    "path": "src/main/java/mltk/predictor/io/PredictorReader.java",
    "chars": 2382,
    "preview": "package mltk.predictor.io;\n\nimport java.io.BufferedReader;\nimport java.io.FileReader;\n\nimport mltk.predictor.Predictor;\n"
  },
  {
    "path": "src/main/java/mltk/predictor/io/PredictorWriter.java",
    "chars": 518,
    "preview": "package mltk.predictor.io;\n\nimport java.io.PrintWriter;\n\nimport mltk.predictor.Predictor;\n\n/**\n * Class for writing pred"
  },
  {
    "path": "src/main/java/mltk/predictor/io/package-info.java",
    "chars": 90,
    "preview": "/**\n * Provides classes for reading and writing predictors.\n */\npackage mltk.predictor.io;"
  },
  {
    "path": "src/main/java/mltk/predictor/package-info.java",
    "chars": 82,
    "preview": "/**\n * Provides interfaces and classes for predictors.\n */\npackage mltk.predictor;"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/DecisionTable.java",
    "chars": 3295,
    "preview": "package mltk.predictor.tree;\n\nimport java.io.BufferedReader;\nimport java.io.PrintWriter;\nimport java.util.Arrays;\n\nimpor"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/DecisionTableLearner.java",
    "chars": 21933,
    "preview": "package mltk.predictor.tree;\n\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.HashMap;\nimport"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/RTree.java",
    "chars": 370,
    "preview": "package mltk.predictor.tree;\n\nimport mltk.predictor.Regressor;\n\n/**\n * Interface for regression trees.\n * \n * @author Yi"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/RTreeLearner.java",
    "chars": 2504,
    "preview": "package mltk.predictor.tree;\n\nimport java.util.Collections;\nimport java.util.List;\n\nimport mltk.core.Instance;\nimport ml"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/RegressionTree.java",
    "chars": 2485,
    "preview": "package mltk.predictor.tree;\n\nimport java.io.BufferedReader;\nimport java.io.PrintWriter;\n\nimport mltk.core.Instance;\n\n/*"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/RegressionTreeLeaf.java",
    "chars": 1342,
    "preview": "package mltk.predictor.tree;\n\nimport java.io.BufferedReader;\nimport java.io.PrintWriter;\n\n/**\n * Class for regression tr"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/RegressionTreeLearner.java",
    "chars": 15829,
    "preview": "package mltk.predictor.tree;\r\n\r\nimport java.util.ArrayList;\r\nimport java.util.HashMap;\r\nimport java.util.List;\r\nimport j"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/TreeInteriorNode.java",
    "chars": 2554,
    "preview": "package mltk.predictor.tree;\n\nimport java.io.BufferedReader;\nimport java.io.PrintWriter;\n\nimport mltk.core.Instance;\n\n/*"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/TreeLearner.java",
    "chars": 7061,
    "preview": "package mltk.predictor.tree;\n\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Collections;\nimport "
  },
  {
    "path": "src/main/java/mltk/predictor/tree/TreeNode.java",
    "chars": 377,
    "preview": "package mltk.predictor.tree;\n\nimport mltk.core.Copyable;\nimport mltk.core.Writable;\n\n/**\n * Abstract class for tree node"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/ensemble/BaggedRTrees.java",
    "chars": 872,
    "preview": "package mltk.predictor.tree.ensemble;\r\n\r\nimport java.util.ArrayList;\r\n\r\nimport mltk.core.Instance;\r\nimport mltk.predicto"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/ensemble/BoostedDTables.java",
    "chars": 6446,
    "preview": "package mltk.predictor.tree.ensemble;\n\nimport java.io.BufferedReader;\nimport java.io.PrintWriter;\nimport java.util.Array"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/ensemble/BoostedRTrees.java",
    "chars": 1747,
    "preview": "package mltk.predictor.tree.ensemble;\n\nimport java.io.BufferedReader;\nimport java.io.PrintWriter;\nimport java.util.Array"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/ensemble/RTreeList.java",
    "chars": 1892,
    "preview": "package mltk.predictor.tree.ensemble;\r\n\r\nimport java.util.ArrayList;\r\nimport java.util.Iterator;\r\nimport java.util.List;"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/ensemble/TreeEnsembleLearner.java",
    "chars": 476,
    "preview": "package mltk.predictor.tree.ensemble;\n\nimport mltk.predictor.HoldoutValidatedLearner;\nimport mltk.predictor.tree.TreeLea"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/ensemble/ag/AdditiveGroves.java",
    "chars": 2092,
    "preview": "package mltk.predictor.tree.ensemble.ag;\r\n\r\nimport java.io.BufferedReader;\r\nimport java.io.PrintWriter;\r\nimport java.uti"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/ensemble/ag/AdditiveGrovesLearner.java",
    "chars": 19216,
    "preview": "package mltk.predictor.tree.ensemble.ag;\n\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\ni"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/ensemble/ag/package-info.java",
    "chars": 109,
    "preview": "/**\r\n * Provides algorithms for fitting additive groves (AGs).\r\n */\r\npackage mltk.predictor.tree.ensemble.ag;"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/ensemble/brt/BDT.java",
    "chars": 3451,
    "preview": "package mltk.predictor.tree.ensemble.brt;\r\n\r\nimport java.io.BufferedReader;\r\nimport java.io.PrintWriter;\r\n\r\nimport mltk."
  },
  {
    "path": "src/main/java/mltk/predictor/tree/ensemble/brt/BRT.java",
    "chars": 2841,
    "preview": "package mltk.predictor.tree.ensemble.brt;\r\n\r\nimport java.io.BufferedReader;\r\nimport java.io.PrintWriter;\r\n\r\nimport mltk."
  },
  {
    "path": "src/main/java/mltk/predictor/tree/ensemble/brt/BRTLearner.java",
    "chars": 1744,
    "preview": "package mltk.predictor.tree.ensemble.brt;\n\nimport mltk.predictor.tree.RegressionTreeLearner.Mode;\nimport mltk.predictor."
  },
  {
    "path": "src/main/java/mltk/predictor/tree/ensemble/brt/BRTUtils.java",
    "chars": 935,
    "preview": "package mltk.predictor.tree.ensemble.brt;\n\nimport mltk.predictor.tree.TreeLearner;\nimport mltk.predictor.tree.DecisionTa"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/ensemble/brt/LADBoostLearner.java",
    "chars": 10328,
    "preview": "package mltk.predictor.tree.ensemble.brt;\n\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.HashMap"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/ensemble/brt/LSBoostLearner.java",
    "chars": 8256,
    "preview": "package mltk.predictor.tree.ensemble.brt;\n\nimport java.util.Arrays;\nimport java.util.List;\n\nimport mltk.cmdline.Argument"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/ensemble/brt/LogitBoostLearner.java",
    "chars": 20149,
    "preview": "package mltk.predictor.tree.ensemble.brt;\n\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\n\n"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/ensemble/brt/RobustDecisionTableLearner.java",
    "chars": 2602,
    "preview": "package mltk.predictor.tree.ensemble.brt;\n\nimport java.util.Collections;\nimport java.util.List;\n\nimport mltk.core.Instan"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/ensemble/brt/RobustRegressionTreeLearner.java",
    "chars": 2734,
    "preview": "package mltk.predictor.tree.ensemble.brt;\n\nimport java.util.Collections;\nimport java.util.List;\n\nimport mltk.core.Instan"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/ensemble/brt/package-info.java",
    "chars": 120,
    "preview": "/**\r\n * Provides algorithms for fitting boosted regression trees (BRTs).\r\n */\r\npackage mltk.predictor.tree.ensemble.brt;"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/ensemble/package-info.java",
    "chars": 95,
    "preview": "/**\n * Provides algorithms for tree ensemble methods.\n */\npackage mltk.predictor.tree.ensemble;"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/ensemble/rf/RandomForest.java",
    "chars": 2415,
    "preview": "package mltk.predictor.tree.ensemble.rf;\n\nimport java.io.BufferedReader;\nimport java.io.PrintWriter;\n\nimport mltk.core.I"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/ensemble/rf/RandomForestLearner.java",
    "chars": 4920,
    "preview": "package mltk.predictor.tree.ensemble.rf;\n\nimport mltk.cmdline.Argument;\nimport mltk.cmdline.CmdLineParser;\nimport mltk.c"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/ensemble/rf/RandomRegressionTreeLearner.java",
    "chars": 4250,
    "preview": "package mltk.predictor.tree.ensemble.rf;\r\n\r\nimport java.util.ArrayList;\r\nimport java.util.HashSet;\r\nimport java.util.Lis"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/ensemble/rf/package-info.java",
    "chars": 105,
    "preview": "/**\n * Provides algorithms for fitting random forests (RFs).\n */\npackage mltk.predictor.tree.ensemble.rf;"
  },
  {
    "path": "src/main/java/mltk/predictor/tree/package-info.java",
    "chars": 83,
    "preview": "/**\n * Provides algorithms for tree-based methods.\n */\npackage mltk.predictor.tree;"
  },
  {
    "path": "src/main/java/mltk/util/ArrayUtils.java",
    "chars": 6377,
    "preview": "package mltk.util;\n\nimport java.util.Arrays;\nimport java.util.List;\n\n/**\n * Class for utility functions for arrays.\n * \n"
  },
  {
    "path": "src/main/java/mltk/util/Element.java",
    "chars": 543,
    "preview": "package mltk.util;\n\n/**\n * Class for weighted elements.\n * \n * @author Yin Lou\n * \n * @param <T> the type of the element"
  },
  {
    "path": "src/main/java/mltk/util/MathUtils.java",
    "chars": 2744,
    "preview": "package mltk.util;\n\n/**\n * Class for utility functions for math.\n * \n * @author Yin Lou\n * \n */\npublic class MathUtils {"
  },
  {
    "path": "src/main/java/mltk/util/OptimUtils.java",
    "chars": 8512,
    "preview": "package mltk.util;\n\nimport java.util.List;\n\n/**\n * Class for utility functions for optimization.\n * \n * @author Yin Lou\n"
  },
  {
    "path": "src/main/java/mltk/util/Permutation.java",
    "chars": 954,
    "preview": "package mltk.util;\r\n\r\n/**\r\n * Class for handling permutation.\r\n * \r\n * @author Yin Lou\r\n * \r\n */\r\npublic class Permutati"
  },
  {
    "path": "src/main/java/mltk/util/Queue.java",
    "chars": 785,
    "preview": "package mltk.util;\n\nimport java.util.LinkedList;\n\n/**\n * Class for generic queues.\n * \n * @author Yin Lou\n * \n * @param "
  },
  {
    "path": "src/main/java/mltk/util/Random.java",
    "chars": 3015,
    "preview": "package mltk.util;\r\n\r\n/**\r\n * Class for global random object.\r\n * \r\n * @author Yin Lou\r\n * \r\n */\r\npublic class Random {\r"
  },
  {
    "path": "src/main/java/mltk/util/Stack.java",
    "chars": 1160,
    "preview": "package mltk.util;\n\nimport java.util.ArrayList;\nimport java.util.EmptyStackException;\nimport java.util.List;\n\n/**\n * Cla"
  },
  {
    "path": "src/main/java/mltk/util/StatUtils.java",
    "chars": 5392,
    "preview": "package mltk.util;\n\n/**\n * Class for utility functions for computing statistics.\n * \n * @author Yin Lou\n * \n */\npublic c"
  },
  {
    "path": "src/main/java/mltk/util/UFSets.java",
    "chars": 1036,
    "preview": "package mltk.util;\n\n/**\n * Class for union-find sets.\n * \n * @author Yin Lou\n *\n */\npublic class UFSets {\n\t\n\tprivate int"
  },
  {
    "path": "src/main/java/mltk/util/VectorUtils.java",
    "chars": 4753,
    "preview": "package mltk.util;\r\n\r\nimport mltk.core.DenseVector;\r\nimport mltk.core.SparseVector;\r\nimport mltk.core.Vector;\r\n\r\n/**\r\n *"
  },
  {
    "path": "src/main/java/mltk/util/package-info.java",
    "chars": 69,
    "preview": "/**\n * Contains miscellaneous utility classes.\n */\npackage mltk.util;"
  },
  {
    "path": "src/main/java/mltk/util/tuple/DoublePair.java",
    "chars": 1133,
    "preview": "package mltk.util.tuple;\r\n\r\n/**\r\n * CLass for $lt;double, double$gt; pair.\r\n * \r\n * @author Yin Lou\r\n * \r\n */\r\npublic cl"
  },
  {
    "path": "src/main/java/mltk/util/tuple/IntDoublePair.java",
    "chars": 1023,
    "preview": "package mltk.util.tuple;\r\n\r\n/**\r\n * Class for &lt;int, double&gt; pairs.\r\n * \r\n * @author Yin Lou\r\n * \r\n */\r\npublic clas"
  },
  {
    "path": "src/main/java/mltk/util/tuple/IntDoublePairComparator.java",
    "chars": 918,
    "preview": "package mltk.util.tuple;\r\n\r\nimport java.util.Comparator;\r\n\r\n/**\r\n * Class for comparing &lt;int, double&gt; pairs. By de"
  },
  {
    "path": "src/main/java/mltk/util/tuple/IntPair.java",
    "chars": 804,
    "preview": "package mltk.util.tuple;\n\n/**\n * Class for &lt;int, int&gt; pairs.\n * \n * @author Yin Lou\n * \n */\npublic class IntPair {"
  },
  {
    "path": "src/main/java/mltk/util/tuple/IntTriple.java",
    "chars": 1026,
    "preview": "package mltk.util.tuple;\r\n\r\n/**\r\n * Class for &lt;int, int, int&gt; triples.\r\n * \r\n * @author Yin Lou\r\n * \r\n */\r\npublic "
  },
  {
    "path": "src/main/java/mltk/util/tuple/LongDoublePair.java",
    "chars": 1139,
    "preview": "package mltk.util.tuple;\r\n\r\n/**\r\n * Class for &lt;long, double&gt; pairs.\r\n * \r\n * @author Yin Lou\r\n * \r\n */\r\npublic cla"
  },
  {
    "path": "src/main/java/mltk/util/tuple/LongDoublePairComparator.java",
    "chars": 924,
    "preview": "package mltk.util.tuple;\r\n\r\nimport java.util.Comparator;\r\n\r\n/**\r\n * Class for comparing &lt;long, double&gt; pairs. By d"
  },
  {
    "path": "src/main/java/mltk/util/tuple/LongPair.java",
    "chars": 910,
    "preview": "package mltk.util.tuple;\r\n\r\n/**\r\n * Class for &lt;long, long&gt; pairs.\r\n * \r\n * @author Yin Lou\r\n * \r\n */\r\npublic class"
  },
  {
    "path": "src/main/java/mltk/util/tuple/Pair.java",
    "chars": 1301,
    "preview": "package mltk.util.tuple;\r\n\r\n/**\r\n * Class for generic pairs.\r\n * \r\n * @author Yin Lou\r\n * \r\n * @param <T1> the type of t"
  },
  {
    "path": "src/main/java/mltk/util/tuple/Triple.java",
    "chars": 1465,
    "preview": "package mltk.util.tuple;\r\n\r\n/**\r\n * Class for generic triples.\r\n * \r\n * @author Yin Lou\r\n * \r\n * @param <T1> the type of"
  },
  {
    "path": "src/main/java/mltk/util/tuple/package-info.java",
    "chars": 72,
    "preview": "/**\n * Contains utility classes for tuples.\n */\npackage mltk.util.tuple;"
  },
  {
    "path": "src/test/java/mltk/core/BinsTest.java",
    "chars": 759,
    "preview": "package mltk.core;\n\nimport org.junit.Assert;\nimport org.junit.Test;\n\nimport mltk.util.MathUtils;\n\npublic class BinsTest "
  },
  {
    "path": "src/test/java/mltk/core/InstancesTestHelper.java",
    "chars": 2234,
    "preview": "package mltk.core;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic class InstancesTestHelper {\n\t\n\tprivate st"
  },
  {
    "path": "src/test/java/mltk/core/io/AttributesReaderTest.java",
    "chars": 2005,
    "preview": "package mltk.core.io;\n\nimport java.io.BufferedReader;\nimport java.io.ByteArrayInputStream;\nimport java.io.ByteArrayOutpu"
  },
  {
    "path": "src/test/java/mltk/core/io/InstancesReaderTest.java",
    "chars": 338,
    "preview": "package mltk.core.io;\n\nimport org.junit.Assert;\nimport org.junit.Test;\n\nimport mltk.core.Instance;\n\npublic class Instanc"
  },
  {
    "path": "src/test/java/mltk/core/processor/DiscretizerTest.java",
    "chars": 784,
    "preview": "package mltk.core.processor;\n\nimport org.junit.Assert;\nimport org.junit.Test;\n\nimport mltk.core.BinnedAttribute;\nimport "
  },
  {
    "path": "src/test/java/mltk/core/processor/InstancesSplitterTest.java",
    "chars": 2070,
    "preview": "package mltk.core.processor;\n\nimport org.junit.Assert;\nimport org.junit.Test;\n\nimport mltk.core.Instance;\nimport mltk.co"
  },
  {
    "path": "src/test/java/mltk/predictor/evaluation/AUCTest.java",
    "chars": 566,
    "preview": "package mltk.predictor.evaluation;\n\nimport mltk.util.MathUtils;\n\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic"
  },
  {
    "path": "src/test/java/mltk/predictor/evaluation/ConvergenceTesterTest.java",
    "chars": 2446,
    "preview": "package mltk.predictor.evaluation;\n\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic class ConvergenceTesterTest "
  },
  {
    "path": "src/test/java/mltk/predictor/evaluation/ErrorTest.java",
    "chars": 580,
    "preview": "package mltk.predictor.evaluation;\n\nimport mltk.util.MathUtils;\n\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic"
  },
  {
    "path": "src/test/java/mltk/predictor/evaluation/LogLossTest.java",
    "chars": 615,
    "preview": "package mltk.predictor.evaluation;\n\nimport mltk.util.MathUtils;\n\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic"
  },
  {
    "path": "src/test/java/mltk/predictor/evaluation/LogisticLossTest.java",
    "chars": 381,
    "preview": "package mltk.predictor.evaluation;\n\nimport mltk.util.MathUtils;\n\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic"
  },
  {
    "path": "src/test/java/mltk/predictor/evaluation/MAETest.java",
    "chars": 353,
    "preview": "package mltk.predictor.evaluation;\n\nimport mltk.util.MathUtils;\n\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic"
  },
  {
    "path": "src/test/java/mltk/predictor/evaluation/MetricFactoryTest.java",
    "chars": 835,
    "preview": "package mltk.predictor.evaluation;\n\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic class MetricFactoryTest {\n\t\n"
  },
  {
    "path": "src/test/java/mltk/predictor/evaluation/RMSETest.java",
    "chars": 361,
    "preview": "package mltk.predictor.evaluation;\n\nimport mltk.util.MathUtils;\n\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic"
  },
  {
    "path": "src/test/java/mltk/predictor/glm/GLMTest.java",
    "chars": 1424,
    "preview": "package mltk.predictor.glm;\n\nimport java.io.BufferedReader;\nimport java.io.ByteArrayInputStream;\nimport java.io.ByteArra"
  },
  {
    "path": "src/test/java/mltk/predictor/tree/DecisionTableLearnerTest.java",
    "chars": 1404,
    "preview": "package mltk.predictor.tree;\n\nimport java.util.List;\n\nimport org.junit.Assert;\nimport org.junit.Test;\n\nimport mltk.core."
  },
  {
    "path": "src/test/java/mltk/predictor/tree/DecisionTableTest.java",
    "chars": 1609,
    "preview": "package mltk.predictor.tree;\n\nimport java.io.BufferedReader;\nimport java.io.ByteArrayInputStream;\nimport java.io.ByteArr"
  },
  {
    "path": "src/test/java/mltk/predictor/tree/DecisionTableTestHelper.java",
    "chars": 1250,
    "preview": "package mltk.predictor.tree;\n\npublic class DecisionTableTestHelper {\n\t\n\tprivate static DecisionTableTestHelper instance "
  },
  {
    "path": "src/test/java/mltk/predictor/tree/RegressionTreeLearnerTest.java",
    "chars": 1410,
    "preview": "package mltk.predictor.tree;\n\nimport java.util.List;\n\nimport org.junit.Assert;\nimport org.junit.Test;\n\nimport mltk.core."
  },
  {
    "path": "src/test/java/mltk/predictor/tree/RegressionTreeTest.java",
    "chars": 1998,
    "preview": "package mltk.predictor.tree;\n\nimport java.io.BufferedReader;\nimport java.io.ByteArrayInputStream;\nimport java.io.ByteArr"
  },
  {
    "path": "src/test/java/mltk/predictor/tree/RegressionTreeTestHelper.java",
    "chars": 1377,
    "preview": "package mltk.predictor.tree;\n\npublic class RegressionTreeTestHelper {\n\t\n\tprivate static RegressionTreeTestHelper instanc"
  },
  {
    "path": "src/test/java/mltk/predictor/tree/ensemble/BoostedDTablesTest.java",
    "chars": 1589,
    "preview": "package mltk.predictor.tree.ensemble;\n\nimport java.io.BufferedReader;\nimport java.io.ByteArrayInputStream;\nimport java.i"
  },
  {
    "path": "src/test/java/mltk/predictor/tree/ensemble/BoostedRTreesTest.java",
    "chars": 1862,
    "preview": "package mltk.predictor.tree.ensemble;\n\nimport java.io.BufferedReader;\nimport java.io.ByteArrayInputStream;\nimport java.i"
  },
  {
    "path": "src/test/java/mltk/predictor/tree/ensemble/brt/BDTTest.java",
    "chars": 2623,
    "preview": "package mltk.predictor.tree.ensemble.brt;\n\nimport java.io.BufferedReader;\nimport java.io.ByteArrayInputStream;\nimport ja"
  },
  {
    "path": "src/test/java/mltk/predictor/tree/ensemble/brt/BRTTest.java",
    "chars": 2019,
    "preview": "package mltk.predictor.tree.ensemble.brt;\n\nimport java.io.BufferedReader;\nimport java.io.ByteArrayInputStream;\nimport ja"
  },
  {
    "path": "src/test/java/mltk/predictor/tree/ensemble/brt/BRTUtilsTest.java",
    "chars": 4150,
    "preview": "package mltk.predictor.tree.ensemble.brt;\n\nimport org.junit.Assert;\nimport org.junit.Test;\n\nimport mltk.predictor.tree.R"
  },
  {
    "path": "src/test/java/mltk/predictor/tree/ensemble/brt/LogitBoostLearnerTest.java",
    "chars": 873,
    "preview": "package mltk.predictor.tree.ensemble.brt;\n\nimport org.junit.Assert;\nimport org.junit.Test;\n\nimport mltk.core.Instances;\n"
  },
  {
    "path": "src/test/java/mltk/util/ArrayUtilsTest.java",
    "chars": 1198,
    "preview": "package mltk.util;\n\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic class ArrayUtilsTest {\n\n\t@Test\n\tpublic void "
  },
  {
    "path": "src/test/java/mltk/util/MathUtilsTest.java",
    "chars": 1300,
    "preview": "package mltk.util;\n\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic class MathUtilsTest {\n\t\n\t@Test\n\tpublic void "
  },
  {
    "path": "src/test/java/mltk/util/OptimUtilsTest.java",
    "chars": 1174,
    "preview": "package mltk.util;\n\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic class OptimUtilsTest {\n\n\t@Test\n\tpublic void "
  },
  {
    "path": "src/test/java/mltk/util/StatUtilsTest.java",
    "chars": 1526,
    "preview": "package mltk.util;\n\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic class StatUtilsTest {\n\t\n\tprivate int[] a = {"
  },
  {
    "path": "src/test/java/mltk/util/VectorUtilsTest.java",
    "chars": 1575,
    "preview": "package mltk.util;\n\nimport org.junit.Assert;\nimport org.junit.Test;\n\npublic class VectorUtilsTest {\n\n\t@Test\n\tpublic void"
  }
]

About this extraction

This page contains the full source code of the yinlou/mltk GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 194 files (810.9 KB), approximately 245.2k tokens, and a symbol index with 1520 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!