Skip to content

Add MASE metric#1166

Merged
valer1435 merged 14 commits into
masterfrom
add-mase-metric
Sep 14, 2023
Merged

Add MASE metric#1166
valer1435 merged 14 commits into
masterfrom
add-mase-metric

Conversation

@valer1435

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

@valer1435 valer1435 requested a review from kasyanovse September 7, 2023 13:03
@kasyanovse

Copy link
Copy Markdown
Collaborator

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

RMSE_penalty = 'rmse_pen'


class TimeSeriesForecastingMetricsEnum(QualityMetricsEnum):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Okay

Comment thread requirements.txt Outdated
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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Версия?

Copy link
Copy Markdown
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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

@codecov

codecov Bot commented Sep 7, 2023

Copy link
Copy Markdown

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

aim-pep8-bot commented Sep 7, 2023

Copy link
Copy Markdown

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

valer1435 commented Sep 7, 2023

Copy link
Copy Markdown
Collaborator Author

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

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

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

@YamLyubov YamLyubov left a comment

Copy link
Copy Markdown
Collaborator

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
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 <32017472+valer1435@users.noreply.github.com>
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