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

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

package weka.filters.unsupervised.attribute;

import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Random;
import java.util.Vector;

import weka.core.*;
import weka.core.Capabilities.Capability;
import weka.core.TechnicalInformation.Field;
import weka.core.TechnicalInformation.Type;
import weka.filters.Filter;
import weka.filters.UnsupervisedFilter;

/**
 * 
 * Reduces the dimensionality of the data by projecting it onto a lower dimensional subspace using a random matrix with columns of unit length. It will reduce the number of attributes in the data while preserving much of its variation like PCA, but at a much less computational cost.
* It first applies the NominalToBinary filter to convert all attributes to numeric before reducing the dimension. It preserves the class attribute.
*
* For more information, see:
*
* Dmitriy Fradkin, David Madigan: Experiments with random projections for machine learning. In: KDD '03: Proceedings of the ninth ACM SIGKDD international conference on Knowledge discovery and data mining, New York, NY, USA, 517-522, 003. *

* * * * BibTeX: *

 * @inproceedings{Fradkin003,
 *    address = {New York, NY, USA},
 *    author = {Dmitriy Fradkin and David Madigan},
 *    booktitle = {KDD '03: Proceedings of the ninth ACM SIGKDD international conference on Knowledge discovery and data mining},
 *    pages = {517-522},
 *    publisher = {ACM Press},
 *    title = {Experiments with random projections for machine learning},
 *    year = {003}
 * }
 * 
*

* * * * Valid options are:

* *

 -N <number>
 *  The number of dimensions (attributes) the data should be reduced to
 *  (default 10; exclusive of the class attribute, if it is set).
* *
 -D [SPARSE1|SPARSE2|GAUSSIAN]
 *  The distribution to use for calculating the random matrix.
 *  Sparse1 is:
 *    sqrt(3)*{-1 with prob(1/6), 0 with prob(2/3), +1 with prob(1/6)}
 *  Sparse2 is:
 *    {-1 with prob(1/2), +1 with prob(1/2)}
 * 
* *
 -P <percent>
 *  The percentage of dimensions (attributes) the data should
 *  be reduced to (exclusive of the class attribute, if it is set). The -N
 *  option is ignored if this option is present and is greater
 *  than zero.
* *
 -M
 *  Replace missing values using the ReplaceMissingValues filter instead of just skipping them.
* *
 -R <num>
 *  The random seed for the random number generator used for
 *  calculating the random matrix (default 42).
* * * * @author Ashraf M. Kibriya (amk14@cs.waikato.ac.nz) * @version $Revision: 14609 $ [1.0 - 22 July 2003 - Initial version (Ashraf M. * Kibriya)] */ public class RandomProjection extends Filter implements UnsupervisedFilter, OptionHandler, TechnicalInformationHandler, Randomizable, WeightedInstancesHandler { /** for serialization */ static final long serialVersionUID = 4428905532728645880L; /** Stores the number of dimensions to reduce the data to */ protected int m_k = 10; /** * Stores the dimensionality the data should be reduced to as percentage of * the original dimension */ protected double m_percent = 0.0; /** distribution type: sparse 1 */ public static final int SPARSE1 = 1; /** distribution type: sparse 2 */ public static final int SPARSE2 = 2; /** distribution type: gaussian */ public static final int GAUSSIAN = 3; /** * The types of distributions that can be used for calculating the random * matrix */ public static final Tag[] TAGS_DSTRS_TYPE = { new Tag(SPARSE1, "Sparse1"), new Tag(SPARSE2, "Sparse2"), new Tag(GAUSSIAN, "Gaussian"), }; /** * Stores the distribution to use for calculating the random matrix */ protected int m_distribution = SPARSE1; /** * Should the missing values be replaced using * unsupervised.ReplaceMissingValues filter */ protected boolean m_useReplaceMissing = false; /** Keeps track of output format if it is defined or not */ protected boolean m_OutputFormatDefined = false; /** The NominalToBinary filter applied to the data before this filter */ protected Filter m_ntob; /** The ReplaceMissingValues filter */ protected Filter m_replaceMissing; /** Stores the random seed used to generate the random matrix */ protected int m_rndmSeed = 42; /** The random matrix */ protected double m_rmatrix[][]; /** The random number generator used for generating the random matrix */ protected Random m_random; /** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options. */ @Override public Enumeration

Ads help maintain this website.