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

weka.filters.supervised.attribute.ClassOrder Maven / Gradle / Ivy

Go to download

The Waikato Environment for Knowledge Analysis (WEKA), a machine learning workbench. This version represents the developer version, the "bleeding edge" of development, you could say. New functionality gets added to this version.

There is a newer version: 3.9.6
Show newest version
/*
 *   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 .
 */

/*
 *    ClassOrder.java
 *    Copyright (C) 2002-2012 University of Waikato, Hamilton, New Zealand
 *
 */
package weka.filters.supervised.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.filters.Filter;
import weka.filters.SupervisedFilter;

/**
 *  Changes the order of the classes so that the class
 * values are no longer of in the order specified in the header. The values will
 * be in the order specified by the user -- it could be either in
 * ascending/descending order by the class frequency or in random order.
 * 

* * * Valid options are: *

* *

 * -R <seed>
 *  Specify the seed of randomization
 *  used to randomize the class
 *  order (default: 1)
 * 
* *
 * -C <order>
 *  Specify the class order to be
 *  sorted, could be 0: ascending
 *  1: descending and 2: random.(default: 0)
 * 
* * * * @author Xin Xu ([email protected]) * @author Eibe Frank ([email protected]) * @version $Revision: 14508 $ */ public class ClassOrder extends Filter implements SupervisedFilter, OptionHandler, WeightedAttributesHandler, WeightedInstancesHandler { /** for serialization */ static final long serialVersionUID = -2116226838887628411L; /** The seed of randomization */ private long m_Seed = 1; /** The random object */ private Random m_Random = null; /** * The 1-1 converting table from the original class values to the new values */ private int[] m_Converter = null; /** Class attribute of the data */ private Attribute m_ClassAttribute = null; /** The class order to be sorted */ private int m_ClassOrder = 0; /** The class values are sorted in ascending order based on their frequencies */ public static final int FREQ_ASCEND = 0; /** The class values are sorted in descending order based on their frequencies */ public static final int FREQ_DESCEND = 1; /** The class values are sorted in random order */ public static final int RANDOM = 2; /** * This class can provide the class distribution in the sorted order as side * effect */ private double[] m_ClassCounts = null; /** * Returns a string describing this filter * * @return a description of the filter suitable for displaying in the * explorer/experimenter gui */ public String globalInfo() { return "Changes the order of the classes so that the class values are " + "no longer of in the order specified in the header. " + "The values will be in the order specified by the user " + "-- it could be either in ascending/descending order by the class " + "frequency or in random order."; } /** * 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