[Home] DMelt member access. Java source code: weka.filters.unsupervised.attribute.NumericToBinary
/*
* 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 .
*/
/*
* NumericToBinary.java
* Copyright (C) 1999-2012 University of Waikato, Hamilton, New Zealand
*
*/
package weka.filters.unsupervised.attribute;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Vector;
import weka.core.*;
import weka.core.Capabilities.Capability;
import weka.filters.StreamableFilter;
import weka.filters.UnsupervisedFilter;
/**
* Converts all numeric attributes into binary
* attributes (apart from the class attribute, if set): if the value of the
* numeric attribute is exactly zero, the value of the new attribute will be
* zero. If the value of the numeric attribute is missing, the value of the new
* attribute will be missing. Otherwise, the value of the new attribute will be
* one. The new attributes will be nominal.
*
*
*
* Valid options are:
*
*
*
* -unset-class-temporarily
* Unsets the class index temporarily before the filter is
* applied to the data.
* (default: no)
*
*
*
*
* @author Eibe Frank (eibe@cs.waikato.ac.nz)
* @version $Revision: 14508 $
*/
public class NumericToBinary extends PotentialClassIgnorer implements
UnsupervisedFilter, StreamableFilter, WeightedInstancesHandler, WeightedAttributesHandler {
/** Stores which columns to turn into binary */
protected Range m_Cols = new Range("first-last");
/** The default columns to turn into binary */
protected String m_DefaultCols = "first-last";
/** for serialization */
static final long serialVersionUID = 2616879323359470802L;
/**
* Returns a string describing this filter
*
* @return a description of the filter suitable for displaying in the
* explorer/experimenter gui
*/
public String globalInfo() {
return "Converts all numeric attributes into binary attributes (apart from "
+ "the class attribute, if set): if the value of the numeric attribute is "
+ "exactly zero, the value of the new attribute will be zero. If the "
+ "value of the numeric attribute is missing, the value of the new "
+ "attribute will be missing. Otherwise, the value of the new "
+ "attribute will be one. The new attributes will be nominal.";
}
/**
* Returns the Capabilities of this filter.
*
* @return the capabilities of this object
* @see Capabilities
*/
@Override
public Capabilities getCapabilities() {
Capabilities result = super.getCapabilities();
result.disableAll();
// attributes
result.enableAllAttributes();
result.enable(Capability.MISSING_VALUES);
// class
result.enableAllClasses();
result.enable(Capability.MISSING_CLASS_VALUES);
result.enable(Capability.NO_CLASS);
return result;
}
/**
* Gets an enumeration describing the available options.
*
* @return an enumeration of all the available options.
*/
@Override
public Enumeration