Converting an equation into MATLAB code

조회 수: 11 (최근 30일)
NeverPerfecT
NeverPerfecT 2018년 4월 22일
댓글: Steven Lord 2023년 6월 27일
I am trying to write a code that calculates the accuracy of my network using sMAPE. The equation is depicted here:
(Y is actual value, F is forecast value, n is the amount of data)
I have written this code (I have 25 data):
e= gsubtract(output,y);
y= net(input);
accuracy = (0.08*mean(abs(e./(abs((output)+(y))))))
"output" on the code above is the target, "y" is the output (sorry for the misleading name with the actual output) Assuming I use the equation above as a reference, is this code correct?
  댓글 수: 2
Walter Roberson
Walter Roberson 2018년 4월 22일
We do not know. How does e relate to Y or F? How does output relate to Y or F ?
NeverPerfecT
NeverPerfecT 2018년 4월 23일
Sorry about that. I edited the question, hope it clears any ambiguity.

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2018년 4월 22일
sMAPE = sum(abs(Y - F) ./ abs(Y + F)) * (2/length(Y))
  댓글 수: 2
NeverPerfecT
NeverPerfecT 2018년 4월 23일
편집: NeverPerfecT 2018년 4월 23일
With this formula I get values that exceeds 1, is this acceptable or is there some parts I did wrong in the training process? Since based on my knowledge, sMAPE is percentage value, if the value exceeds 1, wouldn't the sMAPE exceeds 100%?
Walter Roberson
Walter Roberson 2018년 4월 23일
The forecast value could be negative. That would make (Y-F) increase beyond Y, and Y+F would be less than Y. That would give you a contribution greater than 1 at that point.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

JD Wiley
JD Wiley 2019년 9월 10일
latex2img.png

Gujju
Gujju 2023년 6월 27일
Can someone please create the Matlab code for Equation (6) & (8). Those are curves but I'm getting diefferent results.
  댓글 수: 1
Steven Lord
Steven Lord 2023년 6월 27일
This isn't related to the original question in this discussion, so you should ask it as a separate question using the Ask link near the top of the page. When you ask that separate question, please show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by