Prediction Problem on a regression Problem

5 views (last 30 days)
Kuno Bruswachtl
Kuno Bruswachtl on 17 Feb 2022
Answered: arushi on 5 Sep 2024
Hi,
I have got a problem regarding finding out what my acutual accuracy of the test data is. A short briefing: I have an input of 6570x1x1x7500 for the training data set and a 500x1x1x7500 for as the response training-data set. The reason this being a 4-d array is because I used the function cat to convert it from a cell to an array.
In my layers I only use, fullyConnectedLayer and a BatchNormalization as well as a resize2d to match the output accordingly.
I train the network with the trainNetwork function and get a result of 3.571 as RSME.
Now I want to use the predict function to go and test my test dataset, I do this as follows:
Voxelpred = predict(net, arrTestB );
predictionError = arrTestV - Voxelpred;
numCorrect = sum(abs(predictionError)<10);
numImagesValidation = numel(arrTestV);
accuracy = numCorrect/numImagesValidation;
rmse = sqrt(mean(predictionError.^2))
My problem now is the following:
I do get results, but in the form of 4-D single or if I convert them into double. 4-D double. However I want to know what this would be percentage wise? As well as my Voxelpred should be in the same form as my target Data I trained it with, because as said, I get a 4-D single as response from the predict function. Any ideas?
thanks in advance

Answers (1)

arushi
arushi on 5 Sep 2024
Hi,
I understand that you want to calculate accuracy in percentage and ensure that ‘Voxelpred’ has same format as target data. You can use the “reshape” function to change dimensions of “voxelpred” and to get accuracy you can modify your code as follows:
Voxelpred = predict(net, arrTestB);
Voxelpred = reshape(Voxelpred, size(arrTestV)); % Reshape Voxelpred to match the target data size
predictionError = arrTestV - Voxelpred;
numCorrect = sum(abs(predictionError) < 10);
numImagesValidation = numel(arrTestV);
accuracy = (numCorrect / numImagesValidation) * 100; % Calculate accuracy in percentage
rmse = sqrt(mean(predictionError(:).^2));
I have assumed that “Voxelpred” and “arrTestV” have same number of elements. \
Find below the documentation of “reshape” function.
Hope this helps!

Categories

Find more on Image Data Workflows in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!