All Packages Class Hierarchy This Package Previous Next Index WEKA's home
NNConditionalEstimator newEst = new NNConditionalEstimator();
// Create 50 random points and add them
Random r = new Random(seed);
for(int i = 0; i < 50; i++) {
int x = Math.abs(r.nextInt() % 100);
int y = Math.abs(r.nextInt() % 100);
System.out.println("# " + x + " " + y);
newEst.addValue(x, y, 1);
}
// Pick a random conditional value
int cond = Math.abs(r.nextInt() % 100);
System.out.println("## Conditional = " + cond);
// Print the probabilities conditional on that value
Estimator result = newEst.getEstimator(cond);
for(int i = 0; i <= 100; i+= 5) {
System.out.println(" " + i + " " + result.getProbability(i));
}
public void addValue(double data,
double given,
double weight)
data - the new data value
given - the new value that data is conditional upon
weight - the weight assigned to the data value
public Estimator getEstimator(double given)
given - the new value that data is conditional upon
public double getProbability(double data,
double given)
data - the value to estimate the probability of
given - the new value that data is conditional upon
All Packages Class Hierarchy This Package Previous Next Index WEKA's home