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

weka.attributeSelection.OneRAttributeEval 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 .
 */

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

package weka.attributeSelection;

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

import weka.classifiers.AbstractClassifier;
import weka.classifiers.Classifier;
import weka.classifiers.Evaluation;
import weka.core.Capabilities;
import weka.core.Capabilities.Capability;
import weka.core.Instances;
import weka.core.Option;
import weka.core.OptionHandler;
import weka.core.RevisionUtils;
import weka.core.Utils;
import weka.filters.Filter;
import weka.filters.unsupervised.attribute.Remove;

/**
 *  OneRAttributeEval :
*
* Evaluates the worth of an attribute by using the OneR classifier.
*

* * * Valid options are: *

* *

 * -S <seed>
 *  Random number seed for cross validation
 *  (default = 1)
 * 
* *
 * -F <folds>
 *  Number of folds for cross validation
 *  (default = 10)
 * 
* *
 * -D
 *  Use training data for evaluation rather than cross validaton
 * 
* *
 * -B <minimum bucket size>
 *  Minimum number of objects in a bucket
 *  (passed on to OneR, default = 6)
 * 
* * * * @author Mark Hall ([email protected]) * @version $Revision: 10172 $ */ public class OneRAttributeEval extends ASEvaluation implements AttributeEvaluator, OptionHandler { /** for serialization */ static final long serialVersionUID = 4386514823886856980L; /** The training instances */ private Instances m_trainInstances; /** Random number seed */ private int m_randomSeed; /** Number of folds for cross validation */ private int m_folds; /** Use training data to evaluate merit rather than x-val */ private boolean m_evalUsingTrainingData; /** Passed on to OneR */ private int m_minBucketSize; /** * Returns a string describing this attribute evaluator * * @return a description of the evaluator suitable for displaying in the * explorer/experimenter gui */ public String globalInfo() { return "OneRAttributeEval :\n\nEvaluates the worth of an attribute by " + "using the OneR classifier.\n"; } /** * Returns a string for this option suitable for display in the gui as a tip * text * * @return a string describing this option */ public String seedTipText() { return "Set the seed for use in cross validation."; } /** * Set the random number seed for cross validation * * @param seed the seed to use */ public void setSeed(int seed) { m_randomSeed = seed; } /** * Get the random number seed * * @return an int value */ public int getSeed() { return m_randomSeed; } /** * Returns a string for this option suitable for display in the gui as a tip * text * * @return a string describing this option */ public String foldsTipText() { return "Set the number of folds for cross validation."; } /** * Set the number of folds to use for cross validation * * @param folds the number of folds */ public void setFolds(int folds) { m_folds = folds; if (m_folds < 2) { m_folds = 2; } } /** * Get the number of folds used for cross validation * * @return the number of folds */ public int getFolds() { return m_folds; } /** * Returns a string for this option suitable for display in the gui as a tip * text * * @return a string describing this option */ public String evalUsingTrainingDataTipText() { return "Use the training data to evaluate attributes rather than " + "cross validation."; } /** * Use the training data to evaluate attributes rather than cross validation * * @param e true if training data is to be used for evaluation */ public void setEvalUsingTrainingData(boolean e) { m_evalUsingTrainingData = e; } /** * Returns a string for this option suitable for display in the gui as a tip * text * * @return a string describing this option */ public String minimumBucketSizeTipText() { return "The minimum number of objects in a bucket " + "(passed to OneR)."; } /** * Set the minumum bucket size used by OneR * * @param minB the minimum bucket size to use */ public void setMinimumBucketSize(int minB) { m_minBucketSize = minB; } /** * Get the minimum bucket size used by oneR * * @return the minimum bucket size used */ public int getMinimumBucketSize() { return m_minBucketSize; } /** * Returns true if the training data is to be used for evaluation * * @return true if training data is to be used for evaluation */ public boolean getEvalUsingTrainingData() { return m_evalUsingTrainingData; } /** * 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