@Test public void testUpdate() { NumericPrediction prediction = new NumericPrediction(1.5f, 1); Example example = new Example(NumericFeature.forValue(2.5f)); prediction.update(example); assertEquals(2.0f, prediction.getPrediction()); }
@Override public synchronized void update(Example train) { NumericFeature target = (NumericFeature) train.getTarget(); int oldCount = getCount(); int newCount = oldCount + 1; setCount(newCount); prediction = (float) ((oldCount / (double) newCount) * prediction + target.getValue() / (double) newCount); }
NumericPrediction extends Prediction { @Override public synchronized void update(Example train) { NumericFeature target = (NumericFeature) train.getTarget(); int oldCount = getCount(); int newCount = oldCount + 1; setCount(newCount); prediction = (float) ((oldCount / (double) newCount) * prediction + target.getValue() / (double) newCount); } }
NumericPrediction extends Prediction { @Override public synchronized void update(Example train) { NumericFeature target = (NumericFeature) train.getTarget(); int oldCount = getCount(); int newCount = oldCount + 1; setCount(newCount); prediction = (float) ((oldCount / (double) newCount) * prediction + target.getValue() / (double) newCount); } NumericPrediction(float prediction, int initialCount); }
NumericPrediction extends Prediction { @Override public synchronized void update(Example train) { NumericFeature target = (NumericFeature) train.getTarget(); int oldCount = getCount(); int newCount = oldCount + 1; setCount(newCount); prediction = (float) ((oldCount / (double) newCount) * prediction + target.getValue() / (double) newCount); } NumericPrediction(float prediction, int initialCount); float getPrediction(); @Override FeatureType getFeatureType(); @Override synchronized void update(Example train); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
NumericPrediction extends Prediction { @Override public synchronized void update(Example train) { NumericFeature target = (NumericFeature) train.getTarget(); int oldCount = getCount(); int newCount = oldCount + 1; setCount(newCount); prediction = (float) ((oldCount / (double) newCount) * prediction + target.getValue() / (double) newCount); } NumericPrediction(float prediction, int initialCount); float getPrediction(); @Override FeatureType getFeatureType(); @Override synchronized void update(Example train); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }