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

weka.filters.supervised.attribute.Discretize 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 .
 */

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

package weka.filters.supervised.attribute;

import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.Vector;

import weka.core.Attribute;
import weka.core.Capabilities;
import weka.core.Capabilities.Capability;
import weka.core.ContingencyTables;
import weka.core.DenseInstance;
import weka.core.Instance;
import weka.core.Instances;
import weka.core.Option;
import weka.core.OptionHandler;
import weka.core.Range;
import weka.core.RevisionUtils;
import weka.core.SparseInstance;
import weka.core.SpecialFunctions;
import weka.core.TechnicalInformation;
import weka.core.TechnicalInformation.Field;
import weka.core.TechnicalInformation.Type;
import weka.core.TechnicalInformationHandler;
import weka.core.Utils;
import weka.core.WeightedInstancesHandler;
import weka.filters.Filter;
import weka.filters.SupervisedFilter;

/**
 
 * An instance filter that discretizes a range of numeric attributes in the dataset into nominal attributes. Discretization is by Fayyad & Irani's MDL method (the default).
*
* For more information, see:
*
* Usama M. Fayyad, Keki B. Irani: Multi-interval discretization of continuousvalued attributes for classification learning. In: Thirteenth International Joint Conference on Articial Intelligence, 1022-1027, 1993.
*
* Igor Kononenko: On Biases in Estimating Multi-Valued Attributes. In: 14th International Joint Conference on Articial Intelligence, 1034-1040, 1995. *

* * BibTeX: *

 * @inproceedings{Fayyad1993,
 *    author = {Usama M. Fayyad and Keki B. Irani},
 *    booktitle = {Thirteenth International Joint Conference on Articial Intelligence},
 *    pages = {1022-1027},
 *    publisher = {Morgan Kaufmann Publishers},
 *    title = {Multi-interval discretization of continuousvalued attributes for classification learning},
 *    volume = {2},
 *    year = {1993}
 * }
 * 
 * @inproceedings{Kononenko1995,
 *    author = {Igor Kononenko},
 *    booktitle = {14th International Joint Conference on Articial Intelligence},
 *    pages = {1034-1040},
 *    title = {On Biases in Estimating Multi-Valued Attributes},
 *    year = {1995},
 *    PS = {http://ai.fri.uni-lj.si/papers/kononenko95-ijcai.ps.gz}
 * }
 * 
*

* * Valid options are:

* *

 -R <col1,col2-col4,...>
 *  Specifies list of columns to Discretize. First and last are valid indexes.
 *  (default none)
* *
 -V
 *  Invert matching sense of column indexes.
* *
 -D
 *  Output binary attributes for discretized attributes.
* *
 -Y
 *  Use bin numbers rather than ranges for discretized attributes.
* *
 -E
 *  Use better encoding of split point for MDL.
* *
 -K
 *  Use Kononenko's MDL criterion.
* *
 -precision <integer>
 *  Precision for bin boundary labels.
 *  (default = 6 decimal places).
* * * @author Len Trigg ([email protected]) * @author Eibe Frank ([email protected]) * @version $Revision: 10231 $ */ public class Discretize extends Filter implements SupervisedFilter, OptionHandler, WeightedInstancesHandler, TechnicalInformationHandler { /** for serialization */ static final long serialVersionUID = -3141006402280129097L; /** Stores which columns to Discretize */ protected Range m_DiscretizeCols = new Range(); /** 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; /** Use better encoding of split point for MDL. */ protected boolean m_UseBetterEncoding = false; /** Use Kononenko's MDL criterion instead of Fayyad et al.'s */ protected boolean m_UseKononenko = false; /** Precision for bin range labels */ protected int m_BinRangePrecision = 6; /** Constructor - initialises the filter */ public Discretize() { setAttributeIndices("first-last"); } /** * Gets an enumeration describing the available options. * * @return an enumeration of all the available options. */ @Override public Enumeration




© 2015 - 2024 Weber Informatics LLC | Privacy Policy