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

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

package weka.filters.unsupervised.attribute;

import java.util.Collections;
import java.util.Enumeration;
import java.util.Vector;

import weka.core.*;
import weka.core.Capabilities.Capability;
import weka.filters.SimpleStreamFilter;

/**
 *  A filter that 'cleanses' the numeric data from
 * values that are too small, too big or very close to a certain value,
 * and sets these values to a pre-defined default.
 * 

* * * Valid options are: *

* *

 * -output-debug-info
 *  Turns on output of debugging information.
 * 
* *
 * -min <double>
 *  The minimum threshold. (default -Double.MAX_VALUE)
 * 
* *
 * -min-default <double>
 *  The minimum threshold below which values are replaced by the corresponding default.
 *  (default -Double.MAX_VALUE)
 * 
* *
 * -max <double>
 *  The maximum threshold above which values are replaced by the corresponding default.
 *  (default Double.MAX_VALUE)
 * 
* *
 * -max-default <double>
 *  The replacement for values larger than the maximum threshold.
 *  (default Double.MAX_VALUE)
 * 
* *
 * -closeto <double>
 *  The value with respect to which closeness is determined. (default 0)
 * 
* *
 * -closeto-default <double>
 *  The replacement for values that are too close to '-closeto'.
 *  (default 0)
 * 
* *
 * -closeto-tolerance <double>
 *  The tolerance for testing whether a value is too close. (default 1E-6)
 * 
* *
 * -decimals <int>
 *  The number of decimals to round to, -1 means no rounding at all.
 *  (default -1)
 * 
* *
 * -R <col1,col2,...>
 *  The list of columns to cleanse, e.g., first-last or first-3,5-last.
 *  (default first-last)
 * 
* *
 * -V
 *  Inverts the matching sense.
 * 
* *
 * -include-class
 *  Whether to include the class in the cleansing.
 *  The class column will always be skipped if this flag is not
 *  present. (default no)
 * 
* * * * @author fracpete (fracpete at waikato dot ac dot nz) * @version $Revision: 14508 $ */ public class NumericCleaner extends SimpleStreamFilter implements WeightedAttributesHandler, WeightedInstancesHandler { /** for serialization */ private static final long serialVersionUID = -352890679895066592L; /** the minimum threshold */ protected double m_MinThreshold = -Double.MAX_VALUE; /** the minimum default replacement value */ protected double m_MinDefault = -Double.MAX_VALUE; /** the maximum threshold */ protected double m_MaxThreshold = Double.MAX_VALUE; /** the maximum default replacement value */ protected double m_MaxDefault = Double.MAX_VALUE; /** the number the values are checked for closeness to */ protected double m_CloseTo = 0; /** the default replacement value for numbers "close-to" */ protected double m_CloseToDefault = 0; /** * the tolerance distance, below which numbers are considered being "close-to" */ protected double m_CloseToTolerance = 1E-6; /** Stores which columns to cleanse */ protected Range m_Cols = new Range("first-last"); /** whether to include the class attribute */ protected boolean m_IncludeClass = false; /** the number of decimals to round to (-1 means no rounding) */ protected int m_Decimals = -1; /** * Returns a string describing this filter. * * @return a description of the filter suitable for displaying in the * explorer/experimenter gui */ @Override public String globalInfo() { return "A filter that 'cleanses' the numeric data from values that are too " + "small, too big or very close to a certain value, and sets " + "these values to a pre-defined default."; } /** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ @Override public Enumeration

Ads help maintain this website.