Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MASE metric #1166

Merged
merged 14 commits into from
Sep 14, 2023
Merged

Add MASE metric #1166

merged 14 commits into from
Sep 14, 2023

Conversation

valer1435
Copy link
Collaborator

  1. MASE metric for time series forecasting task was implemented https://en.wikipedia.org/wiki/Mean_absolute_scaled_error
  2. TimeSeriesForecastingMetricsEnum was created

@kasyanovse
Copy link
Collaborator

Может по умолчанию для Федота ее поставить?

@@ -53,6 +53,18 @@ class RegressionMetricsEnum(QualityMetricsEnum):
RMSE_penalty = 'rmse_pen'


class TimeSeriesForecastingMetricsEnum(QualityMetricsEnum):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А нельзя его унаследовать от RegressionMetricsEnum?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нет. Он требует тренировочную выборку, тк на ней считает ошибку наивного предсказания

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А насколько критично использовать тренировочную выборку? Как будто бы средняя ошибка наивного предсказания не должна кардинально меняться при переходе от тренировочной к тестовой выборке.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нет. Он требует тренировочную выборку, тк на ней считает ошибку наивного предсказания

Но вроде это enum, он ничего не требует...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нет. Он требует тренировочную выборку, тк на ней считает ошибку наивного предсказания

Но вроде это enum, он ничего не требует...

Имею ввиду, что метрика для расчета требует значения ряда на тренировочной выборке, поэтому для регрессии метрика не подходит. Получается, что метрика находится в enum'e регрессии, но вызвать для регрессии мы ее не можем (федот либо упадет, либо переварит, в случае одномерного data.features, но какого-то смысла это иметь не будет)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А насколько критично использовать тренировочную выборку? Как будто бы средняя ошибка наивного предсказания не должна кардинально меняться при переходе от тренировочной к тестовой выборке.

Как я понял, на большом промежутке (тренировочной выборки) мы получим больше информации об изменчивости ряда. Еще одна причина - при горизонте=1, если новое значение равно предыдущему - метрика будет не определена (аналогично, если все новые значения просто равны последнему известному)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Получается, что метрика находится в enum'e регрессии, но вызвать для регрессии мы ее не можем

Это так. Я предлагаю унаследовать TimeSeriesForecastingMetricsEnum от RegressionMetricsEnum, добавив туда одну метрику. И не дублируя остальных универсальных.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Получается, что метрика находится в enum'e регрессии, но вызвать для регрессии мы ее не можем

Это так. Я предлагаю унаследовать TimeSeriesForecastingMetricsEnum от RegressionMetricsEnum, добавив туда одну метрику. И не дублируя остальных универсальных.

https://docs.python.org/3/howto/enum.html#restricted-enum-subclassing - нельзя так, к сожалению

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay

requirements.txt Outdated
@@ -14,6 +14,7 @@ statsmodels>=0.12.0
ete3>=3.1.0
networkx>=2.4, !=2.7.*, !=2.8.1, !=2.8.2, !=2.8.3
scikit_learn>=1.0.0; python_version >= '3.8'
sktime
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Версия?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicl-nno А имеет смысл реализовать расчет метрики с помощью numpy? Чтобы не тянуть стороннюю библиотеку из-за однострочной формулы.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да наверное где-то ещё пригодится для работы с временными рядами. Если поймем что нет - тогда уж упростим.

@codecov
Copy link

codecov bot commented Sep 7, 2023

Codecov Report

Merging #1166 (82e12a9) into master (7cd593e) will increase coverage by 0.01%.
The diff coverage is 88.23%.

@@            Coverage Diff             @@
##           master    #1166      +/-   ##
==========================================
+ Coverage   79.77%   79.78%   +0.01%     
==========================================
  Files         142      142              
  Lines        9863     9880      +17     
==========================================
+ Hits         7868     7883      +15     
- Misses       1995     1997       +2     
Files Changed Coverage Δ
fedot/api/api_utils/metrics.py 91.66% <ø> (ø)
fedot/api/main.py 62.80% <ø> (ø)
fedot/core/composer/metrics.py 92.05% <71.42%> (-0.70%) ⬇️
...edot/core/repository/quality_metrics_repository.py 98.11% <100.00%> (+0.43%) ⬆️

@aim-pep8-bot
Copy link

aim-pep8-bot commented Sep 7, 2023

Hello @valer1435! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2023-09-14 08:07:00 UTC

@valer1435
Copy link
Collaborator Author

valer1435 commented Sep 7, 2023

Может по умолчанию для Федота ее поставить?

Хочу сначала протестировать, насколько это может улучшить результат

image
Хотя глюон использует ее для оптимизации

Copy link
Collaborator

@YamLyubov YamLyubov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно еще в api одновить docstring для metric

@valer1435 valer1435 merged commit 86813fa into master Sep 14, 2023
6 checks passed
YamLyubov added a commit that referenced this pull request Sep 14, 2023
* Remove redundant metrics mapping

* Convert str to MetricsEnum

* Refactor MetricsObjective

* Remove ApiMetrics

* Fix test prediction intervals

* Fix tests

* PEP 8

* Fix paths

* Move to init

* зуз8

* Add MASE metric (#1166)

MASE metric for time series forecasting task was implemented https://en.wikipedia.org/wiki/Mean_absolute_scaled_error
TimeSeriesForecastingMetricsEnum was created

* Review fixes

* Remove redundant metrics mapping

* Convert str to MetricsEnum

* Refactor MetricsObjective

* Remove ApiMetrics

* Fix test prediction intervals

* Fix tests

* PEP 8

* Fix paths

* Move to init

* зуз8

* Review fixes

* Convert str to MetricsEnum

* Refactor MetricsObjective

---------

Co-authored-by: Valerii Pokrovskii <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants