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

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

package weka.datagenerators.classifiers.regression;

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

import weka.core.Attribute;
import weka.core.DenseInstance;
import weka.core.Instance;
import weka.core.Instances;
import weka.core.Option;
import weka.core.RevisionUtils;
import weka.core.Utils;
import weka.filters.unsupervised.attribute.AddExpression;

/**
 *  A data generator for generating y according to a
 * given expression out of randomly generated x.
* E.g., the mexican hat can be generated like this:
* sin(abs(a1)) / abs(a1)
* In addition to this function, the amplitude can be changed and gaussian noise * can be added. *

* * * Valid options are: *

* *

 * -h
 *  Prints this help.
 * 
* *
 * -o <file>
 *  The name of the output file, otherwise the generated data is
 *  printed to stdout.
 * 
* *
 * -r <name>
 *  The name of the relation.
 * 
* *
 * -d
 *  Whether to print debug informations.
 * 
* *
 * -S
 *  The seed for random function (default 1)
 * 
* *
 * -n <num>
 *  The number of examples to generate (default 100)
 * 
* *
 * -A <num>
 *  The amplitude multiplier (default 1.0).
 * 
* *
 * -R <num>..<num>
 *  The range x is randomly drawn from (default -10.0..10.0).
 * 
* *
 * -N <num>
 *  The noise rate (default 0.0).
 * 
* *
 * -V <num>
 *  The noise variance (default 1.0).
 * 
* *
 * -E <expression>
 *  The expression to use for generating y out of x 
 *  (default sin(abs(a1)) / abs(a1)).
 * 
* * * * @author FracPete (fracpete at waikato dot ac dot nz) * @version $Revision: 11504 $ * @see AddExpression * @see MexicanHat */ public class Expression extends MexicanHat { /** for serialization */ static final long serialVersionUID = -4237047357682277211L; /** the expression for computing y */ protected String m_Expression; /** the filter for generating y out of x */ protected AddExpression m_Filter; /** the input data structure for the filter */ protected Instances m_RawData; /** * initializes the generator */ public Expression() { super(); setExpression(defaultExpression()); } /** * Returns a string describing this data generator. * * @return a description of the data generator suitable for displaying in the * explorer/experimenter gui */ @Override public String globalInfo() { return "A data generator for generating y according to a given expression " + "out of randomly generated x.\n" + "E.g., the mexican hat can be generated like this:\n" + " sin(abs(a1)) / abs(a1)\n" + "In addition to this function, the amplitude can be changed and " + "gaussian noise can be added."; } /** * Returns an enumeration describing the available options. * * @return an enumeration of all the available options */ @Override public Enumeration

Ads help maintain this website.