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 Center および File ExchangeFinancial Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by