3-ftransform-forecasting #5

Open
romanov73 wants to merge 27 commits from 3-f-transform into master
Showing only changes of commit cb52a2cce6 - Show all commits

View File

@ -0,0 +1,32 @@
package ru.ulstu.score;
import org.springframework.stereotype.Component;
import ru.ulstu.datamodel.exception.ModelingException;
import ru.ulstu.datamodel.ts.TimeSeries;
import ru.ulstu.datamodel.ts.TimeSeriesValue;
import ru.ulstu.target.AnomalyDifferenceSmoothed;
import java.lang.reflect.InvocationTargetException;
import java.time.LocalDateTime;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import static java.lang.Math.abs;
@Component
public class AnomalyCompressionScore extends ScoreMethod {
private final AnomalyDifferenceSmoothed anomalyDifferenceSmoothed;
public AnomalyCompressionScore(AnomalyDifferenceSmoothed anomalyDifferenceSmoothed) {
super("Smape, %");
this.anomalyDifferenceSmoothed = anomalyDifferenceSmoothed;
}
@Override
public Number evaluate(Map<LocalDateTime, Double> tsValues, TimeSeries model) throws ModelingException, ExecutionException, InterruptedException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
var timeSeriesAnomalyResult = anomalyDifferenceSmoothed.calculate(model);
var timeSeriesAnomaly = anomalyDifferenceSmoothed.calculate(tsValues);
// туду: добавить сравнение аномальных точек
return model.getLength()/tsValues.size() + Math.abs(timeSeriesAnomaly.getLength() - timeSeriesAnomalyResult.getLength());
}
}