Converting an equation into MATLAB code
1 回表示 (過去 30 日間)
古いコメントを表示
I am trying to write a code that calculates the accuracy of my network using sMAPE. The equation is depicted here:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/188169/image.png)
(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
2018 年 4 月 22 日
We do not know. How does e relate to Y or F? How does output relate to Y or F ?
採用された回答
Walter Roberson
2018 年 4 月 22 日
sMAPE = sum(abs(Y - F) ./ abs(Y + F)) * (2/length(Y))
2 件のコメント
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 件)
Gujju
2023 年 6 月 27 日
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1420883/image.png)
Can someone please create the Matlab code for Equation (6) & (8). Those are curves but I'm getting diefferent results.
1 件のコメント
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 Center および File Exchange で Electrophysiology についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!