Package weka.estimators
Class EstimatorUtils
- java.lang.Object
-
- weka.estimators.EstimatorUtils
-
- All Implemented Interfaces:
RevisionHandler
public class EstimatorUtils extends Object implements RevisionHandler
Contains static utility functions for Estimators.- Version:
- $Revision$
- Author:
- Gabi Schmidberger (gabi@cs.waikato.ac.nz)
-
-
Constructor Summary
Constructors Constructor Description EstimatorUtils()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static StringcutpointsToString(double[] cutPoints, boolean[] cutAndLeft)Returns a string representing the cutpoints.static doublefindMinDistance(Instances inst, int attrIndex)Find the minimum distance between values.static InstancesgetInstancesFromClass(Instances data, int classIndex, double classValue)Returns a dataset that contains of all instances of a certain class value.static Vector<Object>getInstancesFromClass(Instances data, int attrIndex, int classIndex, double classValue, Instances workData)Returns a dataset that contains all instances of a certain class value.static InstancesgetInstancesFromValue(Instances data, int index, double v)Returns a dataset that contains of all instances of a certain value for the given attribute.static intgetMinMax(Instances inst, int attrIndex, double[] minMax)Find the minimum and the maximum of the attribute and return it in the last parameter.StringgetRevision()Returns the revision string.static voidwriteCurve(String f, Estimator est, double min, double max, int numPoints)Output of an n points of a density curve.static voidwriteCurve(String f, Estimator est, Estimator classEst, double classIndex, double min, double max, int numPoints)Output of an n points of a density curve.
-
-
-
Method Detail
-
findMinDistance
public static double findMinDistance(Instances inst, int attrIndex)
Find the minimum distance between values. Data is assumed to be sorted based on the given attribute. Missing values are skipped if they are at the beginning or the end of the data.- Parameters:
inst- sorted instances, sortedattrIndex- index of the attribute, they are sorted after- Returns:
- the minimal distance
-
getMinMax
public static int getMinMax(Instances inst, int attrIndex, double[] minMax) throws Exception
Find the minimum and the maximum of the attribute and return it in the last parameter.- Parameters:
inst- instances used to build the estimatorattrIndex- index of the attributeminMax- the array to return minimum and maximum in- Returns:
- number of not missing values
- Throws:
Exception- if parameter minMax wasn't initialized properly
-
getInstancesFromClass
public static Vector<Object> getInstancesFromClass(Instances data, int attrIndex, int classIndex, double classValue, Instances workData)
Returns a dataset that contains all instances of a certain class value.- Parameters:
data- dataset to select the instances fromattrIndex- index of the relevant attributeclassIndex- index of the class attributeclassValue- the relevant class value- Returns:
- a dataset with only
-
getInstancesFromClass
public static Instances getInstancesFromClass(Instances data, int classIndex, double classValue)
Returns a dataset that contains of all instances of a certain class value. Missing values are not dealt with.- Parameters:
data- dataset to select the instances fromclassIndex- index of the class attributeclassValue- the class value- Returns:
- a dataset with only instances of one class value
-
writeCurve
public static void writeCurve(String f, Estimator est, double min, double max, int numPoints) throws Exception
Output of an n points of a density curve. Filename is parameter f + ".curv".- Parameters:
f- string to build filenameest-min-max-numPoints-- Throws:
Exception- if something goes wrong
-
writeCurve
public static void writeCurve(String f, Estimator est, Estimator classEst, double classIndex, double min, double max, int numPoints) throws Exception
Output of an n points of a density curve. Filename is parameter f + ".curv".- Parameters:
f- string to build filenameest-classEst-classIndex-min-max-numPoints-- Throws:
Exception- if something goes wrong
-
getInstancesFromValue
public static Instances getInstancesFromValue(Instances data, int index, double v)
Returns a dataset that contains of all instances of a certain value for the given attribute. Does not deal with missing values.- Parameters:
data- dataset to select the instances fromindex- the index of the attributev- the value- Returns:
- a subdataset with only instances of one value for the attribute
-
cutpointsToString
public static String cutpointsToString(double[] cutPoints, boolean[] cutAndLeft)
Returns a string representing the cutpoints.
-
getRevision
public String getRevision()
Returns the revision string.- Specified by:
getRevisionin interfaceRevisionHandler- Returns:
- the revision
-
-