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

weka.attributeSelection.CostSensitiveSubsetEval Maven / Gradle / Ivy

Go to download

The Waikato Environment for Knowledge Analysis (WEKA), a machine learning workbench. This is the stable version. Apart from bugfixes, this version does not receive any other updates.

There is a newer version: 3.8.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 2 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, write to the Free Software
 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/*
 *    CostSensitiveSubsetEval.java
 *    Copyright (C) 2008 University of Waikato, Hamilton, New Zealand
 *
 */

package  weka.attributeSelection;

import weka.core.OptionHandler;
import weka.core.RevisionUtils;

import java.util.BitSet;
import java.io.Serializable;

/**
 
 * A meta subset evaluator that makes its base subset evaluator cost-sensitive.
 * 

* * Valid options are:

* *

 -C <cost file name>
 *  File name of a cost matrix to use. If this is not supplied,
 *  a cost matrix will be loaded on demand. The name of the
 *  on-demand file is the relation name of the training data
 *  plus ".cost", and the path to the on-demand file is
 *  specified with the -N option.
* *
 -N <directory>
 *  Name of a directory to search for cost files when loading
 *  costs on demand (default current directory).
* *
 -cost-matrix <matrix>
 *  The cost matrix in Matlab single line format.
* *
 -S <integer>
 *  The seed to use for random number generation.
* *
 -W
 *  Full name of base evaluator.
 *  (default: weka.attributeSelection.CfsSubsetEval)
* *
 
 * Options specific to evaluator weka.attributeSelection.CfsSubsetEval:
 * 
* *
 -M
 *  Treat missing values as a seperate value.
* *
 -L
 *  Don't include locally predictive attributes.
* * * @author Mark Hall (mhall{[at]}pentaho{[dot]}com) * @version $Revision: 5562 $ */ public class CostSensitiveSubsetEval extends CostSensitiveASEvaluation implements Serializable, SubsetEvaluator, OptionHandler { /** For serialization */ static final long serialVersionUID = 2924546096103426700L; /** * Default constructor. */ public CostSensitiveSubsetEval() { setEvaluator(new CfsSubsetEval()); } /** * Set the base evaluator. * * @param newEvaluator the evaluator to use. * @throws IllegalArgumentException if the evaluator is not an instance of SubsetEvaluator */ public void setEvaluator(ASEvaluation newEvaluator) throws IllegalArgumentException { if (!(newEvaluator instanceof SubsetEvaluator)) { throw new IllegalArgumentException("Evaluator must be an SubsetEvaluator!"); } m_evaluator = newEvaluator; } /** * Evaluates a subset of attributes. Delegates the actual evaluation to * the base subset evaluator. * * @param subset a bitset representing the attribute subset to be * evaluated * @return the "merit" of the subset * @exception Exception if the subset could not be evaluated */ public double evaluateSubset(BitSet subset) throws Exception { return ((SubsetEvaluator)m_evaluator).evaluateSubset(subset); } /** * Returns the revision string. * * @return the revision */ public String getRevision() { return RevisionUtils.extract("$Revision: 5562 $"); } /** * Main method for testing this class. * * @param args the options */ public static void main (String[] args) { runEvaluator(new CostSensitiveSubsetEval(), args); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy