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

/*
 *    MergeInfrequentNominalValues.java
 *    Copyright (C) 2013 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.SimpleBatchFilter;
import weka.filters.UnsupervisedFilter;

/**
 * 
 * Merges all values of the specified nominal attributes that are insufficiently frequent.
 * 

* * * * Valid options are:

* *

 -N <int>
 *  The minimum frequency for a value to remain (default: 2).
 * 
* *
 -R <range>
 *  Sets list of attributes to act on (or its inverse). 'first and 'last' are accepted as well.'
 *  E.g.: first-5,7,9,20-last
 *  (default: 1,2)
* *
 -V
 *  Invert matching sense (i.e. act on all attributes not specified in list)
* *
 -S
 *  Use short IDs for merged attribute values.
* *
 -output-debug-info
 *  If set, filter is run in debug mode and
 *  may output additional info to the console
* *
 -do-not-check-capabilities
 *  If set, filter capabilities are not checked before filter is built
 *  (use with caution).
* * * * @author Eibe Frank * @version $Revision: ???? $ */ public class MergeInfrequentNominalValues extends SimpleBatchFilter implements UnsupervisedFilter, WeightedAttributesHandler, WeightedInstancesHandler { /** for serialization */ static final long serialVersionUID = 4444337331921333847L; /** Set the minimum frequency for a value not to be merged. */ protected int m_MinimumFrequency = 2; /** Stores which atributes to operate on (or nto) */ protected Range m_SelectCols = new Range(); /** Stores the indexes of the selected attributes in order. */ protected int[] m_SelectedAttributes; /** Indicators for which attributes need to be changed. */ protected boolean[] m_AttToBeModified; /** The new values. */ protected int[][] m_NewValues; /** Whether to use short identifiers for merge values. */ protected boolean m_UseShortIDs = false; /** * 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 "Merges all values of the specified nominal attributes that are insufficiently frequent."; } /** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ @Override public Enumeration

Ads help maintain this website.