| java.lang.Object weka.estimators.Estimator
All known Subclasses: weka.classifiers.bayes.net.estimate.DiscreteEstimatorBayes, weka.estimators.PoissonEstimator, weka.estimators.DiscreteEstimator, weka.estimators.NormalEstimator, weka.estimators.KernelEstimator, weka.estimators.MahalanobisEstimator,
Estimator | abstract public class Estimator implements Cloneable,Serializable,OptionHandler,CapabilitiesHandler(Code) | | Abstract class for all estimators.
Example code for a nonincremental estimator
// create a histogram for estimation
EqualWidthEstimator est = new EqualWidthEstimator();
est.addValues(instances, attrIndex);
Example code for an incremental estimator (incremental
estimators must implement interface IncrementalEstimator)
// Create a discrete estimator that takes values 0 to 9
DiscreteEstimator newEst = new DiscreteEstimator(10, true);
// Create 50 random integers first predicting the probability of the
// value, then adding the value to the estimator
Random r = new Random(seed);
for(int i = 0; i < 50; i++) {
current = Math.abs(r.nextInt() % 10);
System.out.println(newEst);
System.out.println("Prediction for " + current
+ " = " + newEst.getProbability(current));
newEst.addValue(current, 1);
}
Example code for a main method for an estimator.
public static void main(String [] argv) {
try {
LoglikeliEstimator est = new LoglikeliEstimator();
Estimator.buildEstimator((Estimator) est, argv, false);
System.out.println(est.toString());
} catch (Exception ex) {
ex.printStackTrace();
System.out.println(ex.getMessage());
}
}
author: Gabi Schmidberger (gabi@cs.waikato.ac.nz) author: Len Trigg (trigg@cs.waikato.ac.nz) version: $Revision: 1.9 $ |
Method Summary | |
public void | addValue(double data, double weight) Add a new data value to the current estimator. | public void | addValues(Instances data, int attrIndex) Initialize the estimator with a new dataset. | public void | addValues(Instances data, int attrIndex, double min, double max, double factor) Initialize the estimator with all values of one attribute of a dataset. | public void | addValues(Instances data, int attrIndex, int classIndex, int classValue) Initialize the estimator using only the instance of one class. | public void | addValues(Instances data, int attrIndex, int classIndex, int classValue, double min, double max) Initialize the estimator using only the instance of one class. | public static void | buildEstimator(Estimator est, String[] options, boolean isIncremental) Build an estimator using the options. | public static void | buildEstimator(Estimator est, Instances instances, int attrIndex, int classIndex, int classValueIndex, boolean isIncremental) | public static Estimator | clone(Estimator model) Creates a deep copy of the given estimator using serialization. | public String | debugTipText() | public boolean | equals(Object obj) | public static Estimator | forName(String name, String[] options) Creates a new instance of a estimatorr given it's class name and
(optional) arguments to pass to it's setOptions method. | public Capabilities | getCapabilities() Returns the Capabilities of this Estimator. | public boolean | getDebug() Get whether debugging is turned on. | public String[] | getOptions() Gets the current settings of the Estimator. | abstract public double | getProbability(double data) Get a probability estimate for a value. | public Enumeration | listOptions() Returns an enumeration describing the available options. | public static Estimator[] | makeCopies(Estimator model, int num) Creates a given number of deep copies of the given estimator using serialization.
Parameters: model - the estimator to copy Parameters: num - the number of estimator copies to create. | public static Estimator | makeCopy(Estimator model) Creates a deep copy of the given estimator using serialization. | public void | setDebug(boolean debug) Set debugging mode. | public void | setOptions(String[] options) Parses a given list of options. | public void | testCapabilities(Instances data, int attrIndex) Test if the estimator can handle the data. |
m_classValueIndex | protected double m_classValueIndex(Code) | | The class value index is > -1 if subset is taken with specific class value only
|
serialVersionUID | final static long serialVersionUID(Code) | | for serialization
|
addValue | public void addValue(double data, double weight)(Code) | | Add a new data value to the current estimator.
Parameters: data - the new data value Parameters: weight - the weight assigned to the data value |
addValues | public void addValues(Instances data, int attrIndex) throws Exception(Code) | | Initialize the estimator with a new dataset.
Finds min and max first.
Parameters: data - the dataset used to build this estimator Parameters: attrIndex - attribute the estimator is for exception: Exception - if building of estimator goes wrong |
addValues | public void addValues(Instances data, int attrIndex, double min, double max, double factor) throws Exception(Code) | | Initialize the estimator with all values of one attribute of a dataset.
Some estimator might ignore the min and max values.
Parameters: data - the dataset used to build this estimator Parameters: attrIndex - attribute the estimator is for Parameters: min - minimal border of range Parameters: max - maximal border of range Parameters: factor - number of instances has been reduced to that factor exception: Exception - if building of estimator goes wrong |
addValues | public void addValues(Instances data, int attrIndex, int classIndex, int classValue) throws Exception(Code) | | Initialize the estimator using only the instance of one class.
It is using the values of one attribute only.
Parameters: data - the dataset used to build this estimator Parameters: attrIndex - attribute the estimator is for Parameters: classIndex - index of the class attribute Parameters: classValue - the class value exception: Exception - if building of estimator goes wrong |
addValues | public void addValues(Instances data, int attrIndex, int classIndex, int classValue, double min, double max) throws Exception(Code) | | Initialize the estimator using only the instance of one class.
It is using the values of one attribute only.
Parameters: data - the dataset used to build this estimator Parameters: attrIndex - attribute the estimator is for Parameters: classIndex - index of the class attribute Parameters: classValue - the class value Parameters: min - minimal value of this attribute Parameters: max - maximal value of this attribute exception: Exception - if building of estimator goes wrong |
buildEstimator | public static void buildEstimator(Estimator est, String[] options, boolean isIncremental) throws Exception(Code) | | Build an estimator using the options. The data is given in the options.
Parameters: est - the estimator used Parameters: options - the list of options Parameters: isIncremental - true if estimator is incremental exception: Exception - if something goes wrong or the user requests help oncommand options |
buildEstimator | public static void buildEstimator(Estimator est, Instances instances, int attrIndex, int classIndex, int classValueIndex, boolean isIncremental) throws Exception(Code) | | |
clone | public static Estimator clone(Estimator model) throws Exception(Code) | | Creates a deep copy of the given estimator using serialization.
Parameters: model - the estimator to copy a deep copy of the estimator exception: Exception - if an error occurs |
debugTipText | public String debugTipText()(Code) | | Returns the tip text for this property
tip text for this property suitable fordisplaying in the explorer/experimenter gui |
equals | public boolean equals(Object obj)(Code) | | Tests whether the current estimation object is equal to another
estimation object
Parameters: obj - the object to compare against true if the two objects are equal |
forName | public static Estimator forName(String name, String[] options) throws Exception(Code) | | Creates a new instance of a estimatorr given it's class name and
(optional) arguments to pass to it's setOptions method. If the
classifier implements OptionHandler and the options parameter is
non-null, the classifier will have it's options set.
Parameters: name - the fully qualified class name of the estimatorr Parameters: options - an array of options suitable for passing to setOptions. Maybe null. the newly created classifier, ready for use. exception: Exception - if the classifier name is invalid, or the optionssupplied are not acceptable to the classifier |
getCapabilities | public Capabilities getCapabilities()(Code) | | Returns the Capabilities of this Estimator. Derived estimators have to
override this method to enable capabilities.
the capabilities of this object See Also: Capabilities |
getDebug | public boolean getDebug()(Code) | | Get whether debugging is turned on.
true if debugging output is on |
getOptions | public String[] getOptions()(Code) | | Gets the current settings of the Estimator.
an array of strings suitable for passing to setOptions |
getProbability | abstract public double getProbability(double data)(Code) | | Get a probability estimate for a value.
Parameters: data - the value to estimate the probability of the estimated probability of the supplied value |
listOptions | public Enumeration listOptions()(Code) | | Returns an enumeration describing the available options.
an enumeration of all the available options. |
makeCopies | public static Estimator[] makeCopies(Estimator model, int num) throws Exception(Code) | | Creates a given number of deep copies of the given estimator using serialization.
Parameters: model - the estimator to copy Parameters: num - the number of estimator copies to create. an array of estimators. exception: Exception - if an error occurs |
makeCopy | public static Estimator makeCopy(Estimator model) throws Exception(Code) | | Creates a deep copy of the given estimator using serialization.
Parameters: model - the estimator to copy a deep copy of the estimator exception: Exception - if an error occurs |
setDebug | public void setDebug(boolean debug)(Code) | | Set debugging mode.
Parameters: debug - true if debug output should be printed |
setOptions | public void setOptions(String[] options) throws Exception(Code) | | Parses a given list of options. Valid options are:
-D
If set, estimator is run in debug mode and
may output additional info to the console.
Parameters: options - the list of options as an array of strings exception: Exception - if an option is not supported |
testCapabilities | public void testCapabilities(Instances data, int attrIndex) throws Exception(Code) | | Test if the estimator can handle the data.
Parameters: data - the dataset the estimator takes an attribute from Parameters: attrIndex - the index of the attribute See Also: Capabilities |
|
|