[Home] DMelt member access. Java source code: weka.filters.unsupervised.attribute.AddValues
/*
* 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 .
*/
/*
* AddValues.java
* Copyright (C) 2006-2012 University of Waikato, Hamilton, New Zealand
*
*/
package weka.filters.unsupervised.attribute;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Vector;
import weka.core.*;
import weka.core.Capabilities.Capability;
import weka.filters.Filter;
import weka.filters.StreamableFilter;
import weka.filters.UnsupervisedFilter;
/**
* Adds the labels from the given list to an attribute
* if they are missing. The labels can also be sorted in an ascending manner. If
* no labels are provided then only the (optional) sorting applies.
*
*
*
* Valid options are:
*
*
*
* -C <col>
* Sets the attribute index
* (default last).
*
*
*
* -L <label1,label2,...>
* Comma-separated list of labels to add.
* (default: none)
*
*
*
* -S
* Turns on the sorting of the labels.
*
*
*
*
* Based on code from AddValues.
*
* @author FracPete (fracpete at waikato dot ac dot nz)
* @version $Revision: 14508 $
* @see AddValues
*/
public class AddValues extends Filter implements UnsupervisedFilter,
StreamableFilter, OptionHandler, WeightedAttributesHandler, WeightedInstancesHandler {
/** for serialization */
private static final long serialVersionUID = -8100622241742393656L;
/** The attribute's index setting. */
protected SingleIndex m_AttIndex = new SingleIndex("last");
/** The values to add. */
protected ArrayList m_Labels = new ArrayList();
/** Whether to sort the values. */
protected boolean m_Sort = false;
/** the array with the sorted label indices */
protected int[] m_SortedIndices;
/**
* Returns a string describing this filter
*
* @return a description of the filter suitable for displaying in the
* explorer/experimenter gui
*/
public String globalInfo() {
return "Adds the labels from the given list to an attribute if they are "
+ "missing. The labels can also be sorted in an ascending manner. "
+ "If no labels are provided then only the (optional) sorting applies.";
}
/**
* Returns an enumeration describing the available options.
*
* @return an enumeration of all the available options.
*/
@Override
public Enumeration