TRMSE.java [src/csip/cosu] Revision: Date:
/*
* $Id$
*
* This file is part of the Cloud Services Integration Platform (CSIP),
* a Model-as-a-Service framework, API and application suite.
*
* 2012-2022, Olaf David and others, OMSLab, Colorado State University.
*
* OMSLab licenses this file to you under the MIT license.
* See the LICENSE file in the project root for more information.
*/
package csip.cosu;
class TRMSE extends ObjFunc {
@Override
public String name() {
return "Transformed RMSE";
}
@Override
public double eval(double[] obs, double[] sim, double missing) {
checkArrays(sim, obs);
double error = 0;
double z_pred = 0.;
double z_val = 0.;
int len = 0;
for (int i = 0; i < sim.length; i++) {
if (obs[i] > missing) {
z_pred = (Math.pow(1.0 + sim[i], 0.3) - 1.0) / 0.3;
z_val = (Math.pow(1.0 + obs[i], 0.3) - 1.0) / 0.3;
error += (z_pred - z_val) * (z_pred - z_val);
len++;
}
}
if (len == 0)
throw new RuntimeException("No valid len value.");
return Math.sqrt(error / len);
}
@Override
public int direction() {
return -1;
}
@Override
public int optimum() {
return 0;
}
}