show time series statistic
This commit is contained in:
parent
a6183567b9
commit
43d5462e37
@ -12,6 +12,7 @@ import ru.ulstu.datamodel.ts.TimeSeries;
|
||||
import ru.ulstu.datamodel.ts.TimeSeriesValue;
|
||||
import ru.ulstu.db.DbService;
|
||||
import ru.ulstu.service.TimeSeriesService;
|
||||
import ru.ulstu.statistic.StatisticService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@ -27,11 +28,14 @@ import java.util.stream.Stream;
|
||||
public class IndexController {
|
||||
private final TimeSeriesService timeSeriesService;
|
||||
private final DbService dbService;
|
||||
private final StatisticService statisticService;
|
||||
|
||||
public IndexController(TimeSeriesService timeSeriesService,
|
||||
DbService dbService) {
|
||||
DbService dbService,
|
||||
StatisticService statisticService) {
|
||||
this.timeSeriesService = timeSeriesService;
|
||||
this.dbService = dbService;
|
||||
this.statisticService = statisticService;
|
||||
}
|
||||
|
||||
@GetMapping("/")
|
||||
@ -96,6 +100,7 @@ public class IndexController {
|
||||
testForecastValues.addAll(testForecast.getValues().stream().map(TimeSeriesValue::getValue).collect(Collectors.toList()));
|
||||
model.addAttribute("testForecast", testForecastValues.toArray());
|
||||
model.addAttribute("forecastDescription", modelingResult);
|
||||
model.addAttribute("statistic", statisticService.getStatistic(timeSeries));
|
||||
}
|
||||
|
||||
private List<String> getDatesForChart(TimeSeries timeSeries, TimeSeries forecast) {
|
||||
|
@ -40,4 +40,11 @@ public class StatisticService {
|
||||
private Optional<Double> getOptionalValue(Double value) {
|
||||
return Optional.ofNullable(value);
|
||||
}
|
||||
|
||||
public TimeSeriesStatistic getStatistic(TimeSeries timeSeries) {
|
||||
return new TimeSeriesStatistic(getMin(timeSeries),
|
||||
getMax(timeSeries),
|
||||
getAverage(timeSeries),
|
||||
getLength(timeSeries));
|
||||
}
|
||||
}
|
||||
|
36
src/main/java/ru/ulstu/statistic/TimeSeriesStatistic.java
Normal file
36
src/main/java/ru/ulstu/statistic/TimeSeriesStatistic.java
Normal file
@ -0,0 +1,36 @@
|
||||
package ru.ulstu.statistic;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class TimeSeriesStatistic {
|
||||
private Optional<Double> min;
|
||||
private Optional<Double> max;
|
||||
private Optional<Double> average;
|
||||
private Optional<Double> length;
|
||||
|
||||
public TimeSeriesStatistic(Optional<Double> min,
|
||||
Optional<Double> max,
|
||||
Optional<Double> average,
|
||||
Optional<Double> length) {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.average = average;
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
public Optional<Double> getMin() {
|
||||
return min;
|
||||
}
|
||||
|
||||
public Optional<Double> getMax() {
|
||||
return max;
|
||||
}
|
||||
|
||||
public Optional<Double> getAverage() {
|
||||
return average;
|
||||
}
|
||||
|
||||
public Optional<Double> getLength() {
|
||||
return length;
|
||||
}
|
||||
}
|
@ -145,13 +145,20 @@
|
||||
Статистические характеристики временного ряда:
|
||||
</h5>
|
||||
<div th:if="${forecastDescription != null && forecastDescription.timeSeriesMethod != null}">
|
||||
<p> Метод прогнозирования:
|
||||
<span th:text="${forecastDescription.timeSeriesMethod}"/>
|
||||
<p> Длина:
|
||||
<span th:text="${statistic.length.present ? statistic.length.get : 'Не известно'}"/>
|
||||
</p>
|
||||
<hr/>
|
||||
<p> Оценка прогноза по
|
||||
<span th:text="${forecastDescription.score.scoreMethod.name}"/>:
|
||||
<span th:text="${forecastDescription.score.value}"/>
|
||||
<p> Минимальное значение:
|
||||
<span th:text="${statistic.min.present ? statistic.min.get : 'Не известно'}"/>
|
||||
</p>
|
||||
<hr/>
|
||||
<p> Максимальное значение:
|
||||
<span th:text="${statistic.max.present ? statistic.max.get : 'Не известно'}"/>
|
||||
</p>
|
||||
<hr/>
|
||||
<p> Среднее значение:
|
||||
<span th:text="${statistic.average.present ? statistic.average.get : 'Не известно'}"/>
|
||||
</p>
|
||||
<hr/>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user