Effacer les filtres
Effacer les filtres

how to calculte MSE Error of whole data to forecast electricity consumption ?

2 vues (au cours des 30 derniers jours)
Saba Yousaf
Saba Yousaf le 8 Oct 2018
Commenté : Kevin Chng le 8 Oct 2018
I am using program to determine SVM regression performance to forecast electricity consumption. I have total 1461*6 samples for training 365x5 for testing purpose in separate files. i used following following code to predict the electricity consumption.
%load training data dimention 1461*6 Opts = detectImportOptions('svmtrain.txt')
Data = readtable('svmtrain.txt', Opts) predictorNames = {'T', 'Wdi', 'S', 'R','W'}; i = Data(:, predictorNames); predictortrain=table2array(i)
response = Data.kWm% actual response
%Load testing data dimention 365x6 Optss = detectImportOptions('testdata.txt') Datatest = readtable('testdata.txt', Optss)
predictorNamestest = {'T', 'Wdi', 'S', 'R','W'}; j = Datatest(:, predictorNamestest);
predictorstest=table2array(j) rng(35) Mdl = fitrsvm(predictortrain,response,'standardize', true) predicty=predict(Mdl,predictorstest)
MSE=mean((response-predicty').^2) % will calculate column wise result till 365 columns MSE=mean((response'-predicty).^2) % will calculate column wise result till 1461columns
how can i calcute MSE of whole data? as the matrix dimensions of both training and test data are different i-e traing data =1461x6 test data= 365x5. kindly reply me fast if possible?
  1 commentaire
Kevin Chng
Kevin Chng le 8 Oct 2018
Re-organise your code :
%load training data dimension 1461*6
Opts = detectImportOptions('svmtrain.txt');
Data = readtable('svmtrain.txt', Opts);
predictorNames = {'T', 'Wdi', 'S', 'R','W'};
i = Data(:, predictorNames);
predictortrain=table2array(i);
response = Data.kWm;% actual response
%Load testing data dimention 365x6
Optss = detectImportOptions('testdata.txt');
Datatest = readtable('testdata.txt', Optss);
predictorNamestest = {'T', 'Wdi', 'S', 'R','W'};
j = Datatest(:, predictorNamestest);
predictorstest=table2array(j);
rng(35)
Mdl = fitrsvm(predictortrain,response,'standardize', true);
predicty=predict(Mdl,predictorstest);
%will calculate column wise result till 365 columns MSE=mean((response'-predicty).^2) % will calculate column wise result till 1461columns
MSE=mean((response-predicty').^2);
Why don't combine predictorstrain and predictorstest to find MSE of whole data?
WholeSetData=[predictorstrain;predictorstest]
predictWhole = predict(Md1,WholeSetData)
Here we have to get the response from testing data first then combine with the response of train data
responsetesting = Datatest.kWm;
responseWhole = [response;responsetesting];
% calculate MSE of whole dataset
MSEWhole = mean((responseWhole-predictWhole').^2);
Hope it will help you

Connectez-vous pour commenter.

Réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by