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

weka.filters.unsupervised.attribute.RandomSubset Maven / Gradle / Ivy

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

/*
 * RandomSubset.java
 * Copyright (C) 2007-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.Random;
import java.util.Vector;

import weka.core.Attribute;
import weka.core.Capabilities;
import weka.core.Capabilities.Capability;
import weka.core.DenseInstance;
import weka.core.Instance;
import weka.core.Instances;
import weka.core.Option;
import weka.core.RevisionUtils;
import weka.core.Utils;
import weka.filters.SimpleStreamFilter;

/**
 
 * Chooses a random subset of attributes, either an absolute number or a percentage. The class is always included in the output (as the last attribute).
 * 

* * Valid options are:

* *

 -N <double>
 *  The number of attributes to randomly select.
 *  If < 1 then percentage, >= 1 absolute number.
 *  (default: 0.5)
* *
 -V
 *  Invert selection - i.e. randomly remove rather than select.
* *
 -S <int>
 *  The seed value.
 *  (default: 1)
* *
 -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 fracpete (fracpete at waikato dot ac dot nz) * @version $Revision: 12037 $ */ public class RandomSubset extends SimpleStreamFilter { /** for serialization. */ private static final long serialVersionUID = 2911221724251628050L; /** * The number of attributes to randomly choose (>= 1 absolute number of * attributes, < 1 percentage). */ protected double m_NumAttributes = 0.5; /** The seed value. */ protected int m_Seed = 1; /** The indices of the attributes that got selected. */ protected int[] m_Indices = null; /** Whether to randomly remove rather than select */ protected boolean m_invertSelection; /** * 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 "Chooses a random subset of attributes, either an absolute number " + "or a percentage. The class is always included in the output (" + "as the last attribute)."; } /** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ @Override public Enumeration




© 2015 - 2024 Weber Informatics LLC | Privacy Policy