3-ftransform-forecasting #5

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

View File

@ -21,17 +21,26 @@ public class AnomalyDifferenceSmoothed extends Target {
} }
@Override @Override
public TimeSeries calculate(TimeSeries ts) throws ModelingException, ExecutionException, InterruptedException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { public TimeSeries calculate(TimeSeries timeSeries) throws ModelingException, ExecutionException, InterruptedException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
TimeSeries anomalyPoints = new TimeSeries();
TimeSeries residual = new TimeSeries(); TimeSeries residual = new TimeSeries();
ModelingResult modelingResult = timeSeriesService.smoothTimeSeries(ts, "AddTrendAddSeason"); TimeSeries anomalyPoints = new TimeSeries();
var tsResult = modelingResult.getTimeSeries();
double diff = anomalyPoints.getMax().getValue()-anomalyPoints.getMin().getValue(); TimeSeries timeSeriesSmooth = timeSeriesService.smoothTimeSeries(timeSeries, "AddTrendAddSeason").getTimeSeries();
for (int i = 0; i < ts.getLength(); i++) { for (int i = 0; i < timeSeries.getLength(); i++) {
residual.addValue(new TimeSeriesValue(ts.getValue(i).getDate(), Math.abs(ts.getNumericValue(i) - tsResult.getNumericValue(i)))); residual.addValue(new TimeSeriesValue(timeSeries.getValue(i).getDate(),
Math.abs(timeSeries.getNumericValue(i) - timeSeriesSmooth.getNumericValue(i))));
} }
return null;
double diff = timeSeries.getMax().getValue()-timeSeries.getMin().getValue();
for (int i = 0; i < residual.getLength(); i++) {
if (residual.getNumericValue(i)/diff > 0.05) {
anomalyPoints.addValue(new TimeSeriesValue(residual.getValue(i).getDate(),
timeSeries.getNumericValue(i)));
}
}
return anomalyPoints;
} }
} }