Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Adaptation and Asynchronous Prediction Combination #3003

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix the LSTM TODO's
Sn0w3y committed Feb 5, 2025
commit 660350bcff214b4146ede704aef011fb8a2f0c60
Original file line number Diff line number Diff line change
@@ -137,26 +137,14 @@
var dayPlus1SeasonalityFuture = CompletableFuture
.supplyAsync(() -> this.predictSeasonality(channelAddress, now.plusDays(1), hyperParameters));

// var combinePrerequisites = CompletableFuture.allOf(seasonalityFuture,
// trendFuture);

try {
// TODO combinePrerequisites.get();

// Current day prediction
var currentDayPredicted = combine(trendFuture.get(), seasonalityFuture.get());

// Next Day prediction
var plus1DaySeasonalityPrediction = dayPlus1SeasonalityFuture.get();

// Concat current and Nextday
CompletableFuture.allOf(seasonalityFuture, trendFuture, dayPlus1SeasonalityFuture).join();
var currentDayPredicted = combine(trendFuture.join(), seasonalityFuture.join());
var plus1DaySeasonalityPrediction = dayPlus1SeasonalityFuture.join();

Check warning on line 144 in io.openems.edge.predictor.lstm/src/io/openems/edge/predictor/lstm/PredictorLstmImpl.java

Codecov / codecov/patch

io.openems.edge.predictor.lstm/src/io/openems/edge/predictor/lstm/PredictorLstmImpl.java#L142-L144

Added lines #L142 - L144 were not covered by tests
var actualPredicted = concatenateList(currentDayPredicted, plus1DaySeasonalityPrediction);

var baseTimeOfPrediction = now.withMinute(getMinute(now, hyperParameters)).withSecond(0).withNano(0);

return Prediction.from(this.sum, channelAddress, //
baseTimeOfPrediction, //
averageInChunks(actualPredicted));
return Prediction.from(this.sum, channelAddress, baseTimeOfPrediction, averageInChunks(actualPredicted));

Check warning on line 147 in io.openems.edge.predictor.lstm/src/io/openems/edge/predictor/lstm/PredictorLstmImpl.java

Codecov / codecov/patch

io.openems.edge.predictor.lstm/src/io/openems/edge/predictor/lstm/PredictorLstmImpl.java#L147

Added line #L147 was not covered by tests

} catch (Exception e) {
throw new RuntimeException("Error in getting prediction execution", e);
Original file line number Diff line number Diff line change
@@ -93,14 +93,13 @@
// Get the validationDate
var validationDate = this.getDate(validateMap);

/**
* TODO Read an save model.adapt method ReadAndSaveModels.adapt(hyperParameters,
* validateBatchData, validateBatchDate);
*/
new TrainAndValidateBatch(//
constantScaling(removeNegatives(trainingData), 1), trainingDate, //
constantScaling(removeNegatives(validationData), 1), validationDate, //
hyperParameters);
// --- Adapt the model based on validation data before training ---
// We use the preprocessed validation data for adaptation.
ReadAndSaveModels.adapt(hyperParameters, constantScaling(removeNegatives(validationData), 1), validationDate);

Check warning on line 98 in io.openems.edge.predictor.lstm/src/io/openems/edge/predictor/lstm/train/LstmTrain.java

Codecov / codecov/patch

io.openems.edge.predictor.lstm/src/io/openems/edge/predictor/lstm/train/LstmTrain.java#L98

Added line #L98 was not covered by tests

// Perform training and validation in batch
new TrainAndValidateBatch(constantScaling(removeNegatives(trainingData), 1), trainingDate,
constantScaling(removeNegatives(validationData), 1), validationDate, hyperParameters);

Check warning on line 102 in io.openems.edge.predictor.lstm/src/io/openems/edge/predictor/lstm/train/LstmTrain.java

Codecov / codecov/patch

io.openems.edge.predictor.lstm/src/io/openems/edge/predictor/lstm/train/LstmTrain.java#L101-L102

Added lines #L101 - L102 were not covered by tests

this.parent._setLastTrainedTime(hyperParameters.getLastTrainedDate().toInstant().toEpochMilli());
this.parent._setModelError(Collections.min(hyperParameters.getRmsErrorSeasonality()));