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

weka.classifiers.meta.WeightedInstancesHandlerWrapper Maven / Gradle / Ivy

Go to download

The Waikato Environment for Knowledge Analysis (WEKA), a machine learning workbench. This version represents the developer version, the "bleeding edge" of development, you could say. New functionality gets added to this version.

There is a newer version: 3.9.6
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 .
 */

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

package weka.classifiers.meta;

import weka.classifiers.RandomizableSingleClassifierEnhancer;
import weka.core.Instance;
import weka.core.Instances;
import weka.core.Option;
import weka.core.ResampleUtils;
import weka.core.RevisionUtils;
import weka.core.Utils;
import weka.core.WeightedInstancesHandler;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.Random;
import java.util.Vector;

/**
 
 * Generic wrapper around any classifier to enable weighted instances support.
* Uses resampling with weights if the base classifier is not implementing the weka.core.WeightedInstancesHandler interface and there are instance weights other 1.0 present. By default, the training data is passed through to the base classifier if it can handle instance weights. However, it is possible to force the use of resampling with weights as well. *

* * Valid options are:

* *

 -force-resample-with-weights
 *  Forces resampling of weights, regardless of whether
 *  base classifier handles instance weights
* *
 -S <num>
 *  Random number seed.
 *  (default 1)
* *
 -W
 *  Full name of base classifier.
 *  (default: weka.classifiers.rules.ZeroR)
* *
 -output-debug-info
 *  If set, classifier is run in debug mode and
 *  may output additional info to the console
* *
 -do-not-check-capabilities
 *  If set, classifier capabilities are not checked before classifier is built
 *  (use with caution).
* *
 -num-decimal-places
 *  The number of decimal places for the output of numbers in the model (default 2).
* *
 
 * Options specific to classifier weka.classifiers.rules.ZeroR:
 * 
* *
 -output-debug-info
 *  If set, classifier is run in debug mode and
 *  may output additional info to the console
* *
 -do-not-check-capabilities
 *  If set, classifier capabilities are not checked before classifier is built
 *  (use with caution).
* *
 -num-decimal-places
 *  The number of decimal places for the output of numbers in the model (default 2).
* * * @author FracPete (fracpete at waikato dot ac dot nz) * @version $Revision: 12226 $ */ public class WeightedInstancesHandlerWrapper extends RandomizableSingleClassifierEnhancer implements WeightedInstancesHandler { private static final long serialVersionUID = 2980789213434466135L; /** command-line option for resampling with weights. */ public static final String FORCE_RESAMPLE_WITH_WEIGHTS = "force-resample-with-weights"; /** whether to force resampling with weights. */ protected boolean m_ForceResampleWithWeights = false; /** * Returns a string describing classifier * @return a description suitable for * displaying in the explorer/experimenter gui */ public String globalInfo() { return "Generic wrapper around any classifier to enable weighted instances support.\n" + "Uses resampling with weights if the base classifier is not implementing " + "the " + WeightedInstancesHandler.class.getName() + " interface and there " + "are instance weights other than 1.0 present. By default, " + "the training data is passed through to the base classifier if it can handle " + "instance weights. However, it is possible to force the use of resampling " + "with weights as well."; } /** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ public Enumeration




© 2015 - 2024 Weber Informatics LLC | Privacy Policy