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

weka.filters.unsupervised.attribute.AddExpression 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 .
 */

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

package weka.filters.unsupervised.attribute;

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

import weka.core.*;
import weka.core.Capabilities.Capability;
import weka.core.expressionlanguage.common.IfElseMacro;
import weka.core.expressionlanguage.common.JavaMacro;
import weka.core.expressionlanguage.common.MacroDeclarationsCompositor;
import weka.core.expressionlanguage.common.MathFunctions;
import weka.core.expressionlanguage.common.Primitives.DoubleExpression;
import weka.core.expressionlanguage.core.Node;
import weka.core.expressionlanguage.parser.Parser;
import weka.core.expressionlanguage.weka.InstancesHelper;
import weka.filters.Filter;
import weka.filters.StreamableFilter;
import weka.filters.UnsupervisedFilter;

/**
 *  An instance filter that creates a new attribute by
 * applying a mathematical expression to existing attributes. The expression can
 * contain attribute references and numeric constants. Supported operators are :
* +, -, *, /, ^, log, abs, cos, exp, sqrt, floor, ceil, rint, tan, sin, (, )
* Attributes are specified by prefixing with 'a', eg. a7 is attribute number 7 * (starting from 1).
* Example expression : a1^2*a5/log(a7*4.0). *

* * * Valid options are: *

* *

 * -E <expression>
 *  Specify the expression to apply. Eg a1^2*a5/log(a7*4.0).
 *  Supported opperators: ,+, -, *, /, ^, log, abs, cos, 
 *  exp, sqrt, floor, ceil, rint, tan, sin, (, )
 *  (default: 0.0)
 * 
* *
 * -N <name>
 *  Specify the name for the new attribute. (default is the expression provided with -E)
 * 
* *
 * -D
 *  Debug. Names attribute with the postfix parse of the expression.
 * 
* * * * @author Mark Hall ([email protected]) * @version $Revision: 14508 $ */ public class AddExpression extends Filter implements UnsupervisedFilter, StreamableFilter, OptionHandler, WeightedInstancesHandler, WeightedAttributesHandler { /** for serialization */ static final long serialVersionUID = 402130384261736245L; /** The infix expression */ private String m_infixExpression = "0.0"; /** * Name of the new attribute. "expression" length string will use the provided * expression as the new attribute name */ private String m_attributeName = "expression"; /** * If true, makes the attribute name equal to the postfix parse of the * expression */ private boolean m_Debug = false; private DoubleExpression m_Expression = null; private InstancesHelper m_InstancesHelper; /** * Returns a string describing this filter * * @return a description of the filter suitable for displaying in the * explorer/experimenter gui */ public String globalInfo() { return "An instance filter that creates a new attribute by applying a " + "mathematical expression to existing attributes. The expression " + "can contain attribute references and numeric constants. Supported " + "operators are :\n" + "+, -, *, /, ^, log, abs, cos, exp, sqrt, floor, ceil, rint, tan, " + "sin, (, )\n" + "Attributes are specified by prefixing with 'a', eg. a7 is " + "attribute number 7 (starting from 1).\n" + "Example expression : a1^2*a5/log(a7*4.0)."; } /** * 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