-
Notifications
You must be signed in to change notification settings - Fork 5
/
Maximum.m
35 lines (26 loc) · 991 Bytes
/
Maximum.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
predictedValue = max(dColumn2);
nextwindow = previousWindow + windowsize;
predictedRow = [nextwindow, predictedValue];
predictedData = [data; predictedRow];
pColumn1 = predictedData(:,1);
pColumn2 = predictedData(:,2);
% Mean absolute percentage error
err = vColumn2 - pColumn2;
errpct = abs(err)./vColumn2*100; % Absolute percentage error
% Getting rid of weird numbers like infinities and NaNs
errpct(errpct == inf) = 0; %for inf
errpct(errpct == -inf) = 0; %for -inf
errpct(isnan(errpct)) = 0; %for NaN
MAPE = mean(errpct);
display(err);
display(errpct);
display(MAPE);
fprintf('Mean Absolute Percent Error (MAPE) for historical loads: %0.3f%%\n',MAPE);
% Compare forescated data and the actual data
plot(pColumn1, pColumn2); hold all;
plot(vColumn1, vColumn2); hold off;
legend('predicted load', 'Actual load');
title('Actual load VS predicted load (Maximum)','Fontsize', 12,'color','b');
ylabel('Load'); xlabel('Period');
display(predictedValue);
display(predictedData);