how to calculate mape

8 次查看(过去 30 天)
andrew moisidi
andrew moisidi 2021-5-31
回答: Steven Lord 2024-11-20,7:00
hey guys i want help how i can calculate mape and how to calculate which calculates the linear product for the product with price values f
function [a,b,MAPE] = getLinearModel(f)
n = length(f);
A = zeros(1,length(f)-1);
b = zeros(1,length(f)-1);
for i=2:n
if f(i-1) ~= 0
A(i-1) = f(i)/f(i-1);
else
A(i-1) = 1;
end
end
a = median(A); %more robust than mean function
for i=1:length(f)-1
b (i) = f(i)/a*i+b;
end
g0 = median(b);%more robust than mean function
  2 个评论
Image Analyst
Image Analyst 2021-5-31
What is mape? Do you have some definition or formula for it? You never assigned the output variable MAPE in your function so it can't return it.
What does this have to do with image analysis (you tagged it as such)?
What is f? Evidently a vector, not an image.
DGM
DGM 2021-5-31
To calculate MAPE, you'd have to know what any of these variables mean conceptually. Single-letter nondescriptive variable names cannot communicate that information. You'll have to figure that out because you're the only one who can know what your code means without an impractical amount of guessing.
I don't know what this has to do with images either.

请先登录,再进行评论。

回答(2 个)

Omega
Omega 2024-11-20,6:06
Hi,
MAPE (Mean Absolute Percentage Error) is calculated using the formula:
where () are the actual values, and ( ) are the predicted values.
It's difficult to understand what your variables mean because of the acronym names. You can use the following formula by plugging in the values for y_true and y_pred:
% Calculate MAPE
mape = mean(abs((y_true - y_pred) ./ y_true)) * 100;
fprintf('Mean Absolute Percentage Error (MAPE): %.2f%%\n', mape);
Hope it helps!

Steven Lord
Steven Lord 2024-11-20,7:00
The mape function was added to MATLAB in release R2022b.

类别

Help CenterFile Exchange 中查找有关 Financial Data 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by