Example usage for org.apache.commons.math3.stat.regression SimpleRegression getSumSquaredErrors

List of usage examples for org.apache.commons.math3.stat.regression SimpleRegression getSumSquaredErrors

Introduction

In this page you can find the example usage for org.apache.commons.math3.stat.regression SimpleRegression getSumSquaredErrors.

Prototype

public double getSumSquaredErrors() 

Source Link

Document

Returns the <a href="http://www.xycoon.com/SumOfSquares.htm"> sum of squared errors</a> (SSE) associated with the regression model.

Usage

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;
}