Reproduce the annual consumption of a building

1 回表示 (過去 30 日間)
Armel
Armel 2022 年 10 月 24 日
編集済み: Armel 2022 年 11 月 1 日
Hello,
I have the annual consumption of a building in MWh per day. In order to simulate the consumption of this building for the years to come, I would like to create a series of data of the same type (consumption in MWh/day for one year) in a random way but with the same characteristics. That is to say to have the same average (within x%), close minimums and maximums and an equivalent distribution.
I think this would involve AI or Deep Learning. For this I have 3 years available to teach the algorithm the characteristics of my data to reproduce.
Am I clear enough? Do you have any idea how to solve my problem?
Thanks in advance.

回答 (1 件)

Ayush
Ayush 2022 年 10 月 28 日
Kindly use the following link to get started with deep learning using MATLAB.
  3 件のコメント
Ayush
Ayush 2022 年 10 月 31 日
I understand that you need to predict the data by using past 3 years data as input by using regression technique, kindly read about "Deep Learning with Time Series and Sequence Data" and the example provided "Time Series Forecasting Using Deep Learning" in mathworks documentation.
Link for the same is here.
Armel
Armel 2022 年 10 月 31 日
編集済み: Armel 2022 年 11 月 1 日
Hello,
Thanks for the link, I spent the day trying to make the example work for me. I have learned a lot, solved some problems but I don't get a usable result and despite my efforts, I can't solve my problem. Here is the steps I followed : https://www.mathworks.com/help/deeplearning/ug/time-series-forecasting-using-deep-learning.html
Here are the wind data I give to Matlab for training and what I expect in output as well (predicting the wind speed per hour over a year).
I think that learning works. The program is running well so far. When we get to the prediction phase, it doesn't work anymore. The vector YTest :
YTest = predict(net,XTest,SequencePaddingDirection="left");
The YTest vector is not complete, and "NaN" appear very quickly. I work with vectors of dimensions 8760x1 (nb hours in a year). First thing I don't understand.
Therefore the part about RMSE doesn't work, but it's not very serious.
I then tried to run the "close loop forecasting", but the figure it displays doesn't make sense. This is the most blocking point, I don't know how to fix it, the values are weird. I remind that my wind data are between 0m/s and 30m/s. Moreover there is no forecasted curve that appears.
Here is my code, if you have time to look at it to help me I will be very grateful.
load data_vent
data_vent(1:3);
numChannels = size(data_vent{1},1);
figure
tiledlayout(3,1)
for i = 1:3
nexttile
stackedplot(data_vent{i}')
xlabel("Time Step")
end
numObservations = numel(data_vent);
idxTrain = 1:floor(0.9*numObservations);
idxTest = floor(0.9*numObservations)+1:numObservations;
dataTrain = data_vent(idxTrain);
dataTest = data_vent(idxTest);
for n = 1:numel(dataTrain)
X = dataTrain{n};
XTrain{n} = X(:,1:end-1);
TTrain{n} = X(:,2:end);
end
muX = mean(cat(1,XTrain{:}),1);
sigmaX = std(cat(1,XTrain{:}),0,1);
muT = mean(cat(1,TTrain{:}),1);
sigmaT = std(cat(1,TTrain{:}),0,1);
for n = 1:numel(XTrain)
XTrain{n} = (XTrain{n} - muX) ./ sigmaX;
TTrain{n} = (TTrain{n} - muT) ./ sigmaT;
end
layers = [
sequenceInputLayer(numChannels)
lstmLayer(128)
fullyConnectedLayer(numChannels)
regressionLayer];
options = trainingOptions("adam", ...
MaxEpochs=8760, ...
SequencePaddingDirection="left", ...
Shuffle="every-epoch", ...
Plots="training-progress", ...
Verbose=0);
net = trainNetwork(XTrain,TTrain,layers,options);
for n = 1:size(dataTest,1)
X = dataTest{n};
XTest{n} = (X(:,1:end-1) - muX) ./ sigmaX;
TTest{n} = (X(:,2:end) - muT) ./ sigmaT;
end
YTest = predict(net,XTest,SequencePaddingDirection="left");
for i = 1:size(YTest,1)
rmse(i) = sqrt(mean((YTest{i} - TTest{i}).^2,"all"));
end
figure
histogram(rmse)
xlabel("RMSE")
ylabel("Frequency")
mean(rmse)
idx = 2;
X = XTest{idx};
T = TTest{idx};
figure
stackedplot(X',DisplayLabels="Channel " + (1:numChannels))
xlabel("Time Step")
title("Test Observation " + idx)
net = resetState(net);
offset = 75;
[net,~] = predictAndUpdateState(net,X(:,1:offset));
numTimeSteps = size(X,2);
numPredictionTimeSteps = numTimeSteps - offset;
Y = zeros(numChannels,numPredictionTimeSteps);
for t = 1:numPredictionTimeSteps
Xt = X(:,offset+t);
[net,Y(:,t)] = predictAndUpdateState(net,Xt);
end
figure
t = tiledlayout(numChannels,1);
title(t,"Open Loop Forecasting")
for i = 1:numChannels
nexttile
plot(T(i,:))
hold on
plot(offset:numTimeSteps,[T(i,offset) Y(i,:)],'--')
ylabel("Channel " + i)
end
xlabel("Time Step")
nexttile(1)
legend(["Input" "Forecasted"])
net = resetState(net);
offset = size(X,2);
[net,Z] = predictAndUpdateState(net,X);
numPredictionTimeSteps = 2000;
Xt = Z(:,end);
Y = zeros(numChannels,numPredictionTimeSteps);
for t = 1:numPredictionTimeSteps
[net,Y(:,t)] = predictAndUpdateState(net,Xt);
Xt = Y(:,t);
end
numTimeSteps = offset + numPredictionTimeSteps;
figure
t = tiledlayout(numChannels,1);
title(t,"Closed Loop Forecasting")
for i = 1:numChannels
nexttile
plot(T(i,1:offset))
hold on
plot(offset:numTimeSteps,[T(i,offset) Y(i,:)],'--')
ylabel("Channel " + i)
end
xlabel("Time Step")
nexttile(1)
legend(["Input" "Forecasted"])

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by