All Downloads are FREE. Search and download functionalities are using the official Maven repository.

meka.experiment.evaluationstatistics.KeyValuePairs Maven / Gradle / Ivy

Go to download

The MEKA project provides an open source implementation of methods for multi-label classification and evaluation. It is based on the WEKA Machine Learning Toolkit. Several benchmark methods are also included, as well as the pruned sets and classifier chains methods, other methods from the scientific literature, and a wrapper to the MULAN framework.

There is a newer version: 1.9.7
Show newest version
/*
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see .
 */

/**
 * KeyValuePairs.java
 * Copyright (C) 2015 University of Waikato, Hamilton, NZ
 */

package meka.experiment.evaluationstatistics;

import meka.classifiers.multilabel.MultiLabelClassifier;
import meka.core.FileUtils;
import meka.core.OptionUtils;
import weka.core.Instances;
import weka.core.Option;
import weka.core.Utils;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.*;

/**
 * Simple plain text format. One statistics object per line, as tab-separated key-value pairs.
 *
 * @author FracPete (fracpete at waikato dot ac dot nz)
 * @version $Revision$
 */
public class KeyValuePairs
  extends AbstractFileBasedEvaluationStatisticsHandler
  implements OptionalIncrementalEvaluationStatisticsHandler {

	private static final long serialVersionUID = -1090631157162943295L;

	/** the key for the classifier. */
	public final static String KEY_CLASSIFIER = "Classifier";

	/** the key for the relation. */
	public final static String KEY_RELATION = "Relation";

	/** the statistics so far. */
	protected List m_Statistics = new ArrayList<>();

	/** whether the incremental mode is off. */
	protected boolean m_IncrementalDisabled;

	/**
	 * Description to be displayed in the GUI.
	 *
	 * @return      the description
	 */
	public String globalInfo() {
		return "Simple plain text format that places one statistcs result per line, as tab-separated "
				+ "key-value pairs (separated by '=').";
	}

	/**
	 * Returns the format description.
	 *
	 * @return      the file format
	 */
	public String getFormatDescription() {
		return "Key-value pairs";
	}

	/**
	 * Returns the format extension(s).
	 *
	 * @return      the extension(s) (incl dot)
	 */
	public String[] getFormatExtensions() {
		return new String[]{".txt"};
	}

	/**
	 * Sets whether incremental model is turned off.
	 *
	 * @param value     true to turn off incremental mode
	 */
	public void setIncrementalDisabled(boolean value) {
		m_IncrementalDisabled = value;
	}

	/**
	 * Returns whether incremental mode is turned off.
	 *
	 * @return          true if incremental mode is pff
	 */
	public boolean isIncrementalDisabled() {
		return m_IncrementalDisabled;
	}

	/**
	 * Describes this property.
	 *
	 * @return          the description
	 */
	public String incrementalDisabledTipText() {
		return "If enabled, incremental mode is turned off.";
	}

	/**
	 * Returns whether the handler is threadsafe.
	 *
	 * @return      true if threadsafe
	 */
	@Override
	public boolean isThreadSafe() {
		return m_IncrementalDisabled;
	}

	/**
	 * Returns whether the handler supports incremental write.
	 *
	 * @return      true if supported
	 */
	@Override
	public boolean supportsIncrementalUpdate() {
		return !m_IncrementalDisabled;
	}

	/**
	 * Returns an enumeration of all the available options.
	 *
	 * @return an enumeration of all available options.
	 */
	@Override
	public Enumeration




© 2015 - 2024 Weber Informatics LLC | Privacy Policy