/*
 *   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 .
 */

/*
 *    SpreadSubsample.java
 *    Copyright (C) 2002-2012 University of Waikato, Hamilton, New Zealand
 *
 */

package weka.filters.supervised.instance;

import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Random;
import java.util.Vector;

import weka.core.*;
import weka.core.Capabilities.Capability;
import weka.filters.Filter;
import weka.filters.SupervisedFilter;
import weka.gui.ProgrammaticProperty;

/**
 *  Produces a random subsample of a dataset. The
 * original dataset must fit entirely in memory. This filter allows you to
 * specify the maximum "spread" between the rarest and most common class. For
 * example, you may specify that there be at most a 2:1 difference in class
 * frequencies. When used in batch mode, subsequent batches are NOT resampled.
 * 

* * * Valid options are: *

* *

 * -S <num>
 *  Specify the random number seed (default 1)
 * 
* *
 * -M <num>
 *  The maximum class distribution spread.
 *  0 = no maximum spread, 1 = uniform distribution, 10 = allow at most
 *  a 10:1 ratio between the classes (default 0)
 * 
* *
 * -W
 *  Adjust weights so that total weight per class is maintained.
 *  Individual instance weighting is not preserved. (default no
 *  weights adjustment
 * 
* *
 * -X <num>
 *  The maximum count for any class value (default 0 = unlimited).
 * 
* * * * @author Stuart Inglis (stuart@reeltwo.com) * @version $Revision: 14508 $ **/ public class SpreadSubsample extends Filter implements SupervisedFilter, OptionHandler, Randomizable, WeightedAttributesHandler { /** for serialization */ static final long serialVersionUID = -3947033795243930016L; /** The random number generator seed */ private int m_RandomSeed = 1; /** The maximum count of any class */ private int m_MaxCount; /** True if the first batch has been done */ private double m_DistributionSpread = 0; /** * True if instance weights will be adjusted to maintain total weight per * class. */ private boolean m_AdjustWeights = false; /** * Returns a string describing this filter * * @return a description of the filter suitable for displaying in the * explorer/experimenter gui */ public String globalInfo() { return "Produces a random subsample of a dataset. The original dataset must " + "fit entirely in memory. This filter allows you to specify the maximum " + "\"spread\" between the rarest and most common class. For example, you may " + "specify that there be at most a 2:1 difference in class frequencies. " + "When used in batch mode, subsequent batches are NOT resampled."; } /** * Returns the tip text for this property * * @return tip text for this property suitable for displaying in the * explorer/experimenter gui */ public String adjustWeightsTipText() { return "Wether instance weights will be adjusted to maintain total weight per " + "class."; } /** * Returns true if instance weights will be adjusted to maintain total weight * per class. * * @return true if instance weights will be adjusted to maintain total weight * per class. */ public boolean getAdjustWeights() { return m_AdjustWeights; } /** * Sets whether the instance weights will be adjusted to maintain total weight * per class. * * @param newAdjustWeights whether to adjust weights */ public void setAdjustWeights(boolean newAdjustWeights) { m_AdjustWeights = newAdjustWeights; } /** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ @Override public Enumeration

Ads help maintain this website.