List of usage examples for org.apache.commons.math3.stat.regression SimpleRegression getSumSquaredErrors
public double getSumSquaredErrors()
From source file:eu.tango.energymodeller.energypredictor.CpuOnlyEnergyPredictor.java
/** * This calculates the mathematical function that predicts the power * consumption given the cpu utilisation. * * @param host The host to get the function for * @return The mathematical function that predicts the power consumption * given the cpu utilisation./*from w w w .j a v a2s.co m*/ */ private PredictorFunction<LinearFunction> retrieveModel(Host host) { if (modelCache.containsKey(host)) { /** * A small cache avoids recalculating the regression so often. */ return modelCache.get(host); } LinearFunction model = new LinearFunction(); SimpleRegression regressor = new SimpleRegression(true); for (HostEnergyCalibrationData data : host.getCalibrationData()) { regressor.addData(data.getCpuUsage(), data.getWattsUsed()); } model.setIntercept(regressor.getIntercept()); model.setCoefficient(regressor.getSlope()); PredictorFunction<LinearFunction> answer = new PredictorFunction<>(model, regressor.getSumSquaredErrors(), Math.sqrt(regressor.getMeanSquareError())); modelCache.put(host, answer); return answer; }