Prediction Problem on a regression Problem
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
arushi
2024-9-5
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!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!