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

Time consuming report after composition #1257

Merged
merged 12 commits into from
Feb 26, 2024
Merged

Time consuming report after composition #1257

merged 12 commits into from
Feb 26, 2024

Conversation

aPovidlo
Copy link
Collaborator

@aPovidlo aPovidlo commented Feb 8, 2024

Добавление таймера для подсчета времени выполнения основных процессов во время композирования пайплайна:

  • 'Data Definition (fit)'. Определение данных во время вызова метода fit() из API.
  • 'Applying Recommendation (fit)'. Применение стратегии по обработке данных во время вызова метода fit() из API.
  • 'Data Preprocessing'. Время затраченное на обработку данных.
  • 'Fitting'. Время затраченное на обучение каждого пайплайна во время композирования.
  • 'Tuning (composing)'. Время затраченное на тюнинг гиперпараметров во время композирование.
  • 'Tuning (post)'. Время затраченное на тюнинг гиперпараметров сверху при вызове метода tune() из API.
  • 'Data Definition (predict)'. Определение данных во время вызова метода predict() из API.
  • 'Applying Recommendation (predict)'. Применение стратегии по обработке данных во время вызова метода predict() из API.
  • 'Predicting'. Время затраченное на предсказание.

После завершения обучения в композировании, можно вызвать метод return_report() из API, который вернет DataFrame с временем работы конкретной стадии.

@pep8speaks
Copy link

pep8speaks commented Feb 8, 2024

Hello @aPovidlo! 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 2024-02-26 14:44:57 UTC

Copy link
Contributor

github-actions bot commented Feb 8, 2024

All PEP8 errors has been fixed, thanks ❤️

Comment last updated at

from contextlib import contextmanager


class FedotIndustrialTimer:
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

codecov bot commented Feb 8, 2024

Codecov Report

Attention: Patch coverage is 69.84127% with 19 lines in your changes are missing coverage. Please review.

Project coverage is 79.80%. Comparing base (c53881a) to head (d7944b7).

Files Patch % Lines
fedot/api/main.py 59.57% 19 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1257      +/-   ##
==========================================
- Coverage   79.82%   79.80%   -0.03%     
==========================================
  Files         150      150              
  Lines       10322    10344      +22     
==========================================
+ Hits         8240     8255      +15     
- Misses       2082     2089       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@aPovidlo
Copy link
Collaborator Author

aPovidlo commented Feb 8, 2024

/fix-pep8

@nicl-nno nicl-nno requested a review from Nunkyl February 9, 2024 09:08
Copy link
Collaborator

@andreygetmanov andreygetmanov left a comment

Choose a reason for hiding this comment

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

Перед композированием Федот обучается inital pipeline и выдаёт в консоль время его обучения. То же самое происходит, если не включать композирование (передать в API predefined_model=auto, например)
Это время где-то учитывается? Возможно, на стадии 'Data Preprocessing'?
Думаю, может быть полезно вынести это в отдельную строчку отчёта

@aPovidlo
Copy link
Collaborator Author

Перед композированием Федот обучается inital pipeline и выдаёт в консоль время его обучения. То же самое происходит, если не включать композирование (передать в API predefined_model=auto, например)

Соглашусь, что стоит учитывать это.

Это время где-то учитывается? Возможно, на стадии 'Data Preprocessing'?

Не знаю, нужно посмотреть, но навряд ли в обработке.

Думаю, может быть полезно вынести это в отдельную строчку отчёта

Не уверен. Может быть есть смысл все заносить в общее время fit.

@andreygetmanov
Copy link
Collaborator

Не уверен. Может быть есть смысл все заносить в общее время fit.

Да, можно и так
Тогда протестишь, совпадают ли время обучения initial pipeline при заданном predefined model (выводится в консоль) со временем fit в твоём отчёте?
Если да, то апруваю

fedot/utilities/composer_timer.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@andreygetmanov andreygetmanov left a comment

Choose a reason for hiding this comment

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

  1. Мне кажется, для практического применения в целом не так важно знать, сколько времени занимал препроцессинг на каждой стадии обучения (композинг, тюнинг, всё такое). Поэтому выводить суммарное время препроцессинга - это хорошо и удобно, согласен
  2. Я посмотрел на процесс .fit(), и мне кажется, что можно легко рассчитать время композинга, обернув в таймер строчки, где производится композинг. Тогда fitting = composing + tuning (fit) + остатки
  3. Самая весомая часть остатков - это метод train_on_full_dataset. Он может занимать значимое количество времени, потому что обучает модель на всём датасете + может быть информативен и полезен, потому что в связке с Predicting даст понятное представление, сколько времени уже найденная модель фитится, а сколько предиктится. Поэтому можно тоже выводить эту величину в отчёт
  4. И методу report не хватает хорошего докстринга, где будет объяснено, что значит и как считается каждая величина. Например, крайне важным будет указать, что Data Preprocessing - это суммарное время препроцессинга за всё время запуска, а Fitting - это сумма композинга, тюнинга и обучения полученной модели на всём датасете

fedot/api/main.py Outdated Show resolved Hide resolved
fedot/utilities/composer_timer.py Show resolved Hide resolved
fedot/utilities/composer_timer.py Outdated Show resolved Hide resolved
fedot/utilities/composer_timer.py Outdated Show resolved Hide resolved
fedot/api/api_utils/api_composer.py Outdated Show resolved Hide resolved
fedot/utilities/composer_timer.py Outdated Show resolved Hide resolved
self.log.message('Final pipeline was fitted')
else:
self.log.message('Already fitted initial pipeline is used')
with fedot_composer_timer.launch_train_inference():
Copy link
Collaborator

Choose a reason for hiding this comment

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

Только комментарий "# Final fit for obtained pipeline on full dataset" лучше не убирать, наверное

@@ -497,6 +512,28 @@ def explain(self, features: FeaturesType = None,

return explainer

def return_report(self) -> pd.DataFrame:
""" Functions returns report of time-consuming.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Можно немного подправить текст:

Function returns a report on time consumption.

The following steps are presented in this report:
- 'Data Definition (fit)': Time spent on data definition in fit().
- 'Data Preprocessing': Total time spent on preprocessing data, includes fitting and predicting stages.
- 'Fitting (summary)': Total time spent on Composing, Tuning and Training Inference.
- 'Composing': Time spent on searching for the best pipeline.
- 'Train Inference': Time spent on training the pipeline found during composing.
- 'Tuning (composing)': Time spent on hyperparameters tuning in the whole fitting, if with_tune is True.
- 'Tuning (after)': Time spent on .tune() (hyperparameters tuning) after composing.
- 'Data Definition (predict)': Time spent on data definition in predict().
- 'Predicting': Time spent on predicting (inference).


@property
def report(self) -> dict:
""" Return dict with the next columns:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Тут то же самое

  • 'Data Definition (fit)': Time spent on data definition in fit().
  • 'Data Preprocessing': Total time spent on preprocessing data, includes fitting and predicting stages.
  • 'Fitting (summary)': Total time spent on Composing, Tuning and Training Inference.
  • 'Composing': Time spent on searching for the best pipeline.
  • 'Train Inference': Time spent on training the pipeline found during composing.
  • 'Tuning (composing)': Time spent on hyperparameters tuning in whole fitting, if with_tune is True.
  • 'Tuning (after)': Time spent on .tune() (hyperparameters tuning) after composing.
  • 'Data Definition (predict)': Time spent on data definition in predict().
  • 'Predicting': Time spent on predicting (inference).

@aPovidlo aPovidlo merged commit c17381c into master Feb 26, 2024
7 checks passed
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