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

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

package weka.filters.unsupervised.attribute;

import java.util.*;

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

/**
 *  An instance filter that discretizes a range of
 * numeric attributes in the dataset into nominal attributes. Discretization is
 * by simple binning. Skips the class attribute if set.
 * 

* * * Valid options are: *

* *

 * -unset-class-temporarily
 *  Unsets the class index temporarily before the filter is
 *  applied to the data.
 *  (default: no)
 * 
* *
 * -B <num>
 *  Specifies the (maximum) number of bins to divide numeric attributes into.
 *  (default = 10)
 * 
* *
 * -M <num>
 *  Specifies the desired weight of instances per bin for
 *  equal-frequency binning. If this is set to a positive
 *  number then the -B option will be ignored.
 *  (default = -1)
 * 
* *
 * -F
 *  Use equal-frequency instead of equal-width discretization.
 * 
* *
 * -O
 *  Optimize number of bins using leave-one-out estimate
 *  of estimated entropy (for equal-width discretization).
 *  If this is set then the -B option will be ignored.
 * 
* *
 * -R <col1,col2-col4,...>
 *  Specifies list of columns to Discretize. First and last are valid indexes.
 *  (default: first-last)
 * 
* *
 * -V
 *  Invert matching sense of column indexes.
 * 
* *
 * -D
 *  Output binary attributes for discretized attributes.
 * 
* *
 * -Y
 *  Use bin numbers rather than ranges for discretized attributes.
 * 
* *
 -precision <integer>
 *  Precision for bin boundary labels.
 *  (default = 6 decimal places).
* *
-spread-attribute-weight
 *  When generating binary attributes, spread weight of old
 *  attribute across new attributes. Do not give each new attribute the old weight.
* * * * @author Len Trigg (trigg@cs.waikato.ac.nz) * @author Eibe Frank (eibe@cs.waikato.ac.nz) * @version $Revision: 14511 $ */ public class Discretize extends PotentialClassIgnorer implements UnsupervisedFilter, WeightedInstancesHandler, WeightedAttributesHandler { /** for serialization */ static final long serialVersionUID = -1358531742174527279L; /** Stores which columns to Discretize */ protected Range m_DiscretizeCols = new Range(); /** The number of bins to divide the attribute into */ protected int m_NumBins = 10; /** The desired weight of instances per bin */ protected double m_DesiredWeightOfInstancesPerInterval = -1; /** Store the current cutpoints */ protected double[][] m_CutPoints = null; /** Output binary attributes for discretized attributes. */ protected boolean m_MakeBinary = false; /** Use bin numbers rather than ranges for discretized attributes. */ protected boolean m_UseBinNumbers = false; /** Find the number of bins using cross-validated entropy. */ protected boolean m_FindNumBins = false; /** Use equal-frequency binning if unsupervised discretization turned on */ protected boolean m_UseEqualFrequency = false; /** The default columns to discretize */ protected String m_DefaultCols; /** Precision for bin range labels */ protected int m_BinRangePrecision = 6; /** Whether to spread attribute weight when creating binary attributes */ protected boolean m_SpreadAttributeWeight = false; /** Constructor - initialises the filter */ public Discretize() { m_DefaultCols = "first-last"; setAttributeIndices("first-last"); } /** * Another constructor, sets the attribute indices immediately * * @param cols the attribute indices */ public Discretize(String cols) { m_DefaultCols = cols; setAttributeIndices(cols); } /** * Gets an enumeration describing the available options. * * @return an enumeration of all the available options. */ @Override public Enumeration

Ads help maintain this website.