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

Hotfix of fit time estimation for initial assumption #1309

Merged
merged 7 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fedot/api/api_utils/api_composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def propose_and_fit_initial_assumption(self, train_data: InputData) -> Tuple[Seq
use_input_preprocessing=self.params.get(
'use_input_preprocessing'))

with self.timer.launch_assumption_fit():
with self.timer.launch_assumption_fit(n_folds=self.params.data['cv_folds']):
fitted_assumption = \
assumption_handler.fit_assumption_and_check_correctness(deepcopy(initial_assumption[0]),
pipelines_cache=self.pipelines_cache,
Expand Down
11 changes: 8 additions & 3 deletions fedot/api/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self, **time_params):
self.tuning_spend_time = datetime.timedelta(minutes=0)

self.assumption_fit_spend_time = datetime.timedelta(minutes=0)
self.assumption_fit_spend_time_single_fold = datetime.timedelta(minutes=0)

def __define_timeouts_for_stages(self):
""" Determine timeouts for tuning and composing """
Expand Down Expand Up @@ -69,19 +70,23 @@ def launch_tuning(self):
self.tuning_spend_time = datetime.datetime.now() - starting_time_for_tuning

@contextmanager
def launch_assumption_fit(self):
def launch_assumption_fit(self, n_folds: int):
""" Wrap assumption fit process with timer """
starting_time_for_assumption_fit = datetime.datetime.now()
yield
self.assumption_fit_spend_time = datetime.datetime.now() - starting_time_for_assumption_fit
self.assumption_fit_spend_time_single_fold = \
(datetime.datetime.now() - starting_time_for_assumption_fit)
if n_folds is None:
n_folds = 1
self.assumption_fit_spend_time = self.assumption_fit_spend_time_single_fold * n_folds

def determine_resources_for_tuning(self):
"""
Based on time spend for composing and initial pipeline fit determine
how much time and how many iterations are needed for tuning

"""
all_spend_time = self.composing_spend_time + self.assumption_fit_spend_time
all_spend_time = self.composing_spend_time + self.assumption_fit_spend_time_single_fold

if self.time_for_automl is not None:
all_timeout = float(self.time_for_automl)
Expand Down
4 changes: 2 additions & 2 deletions test/unit/optimizer/test_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ def test_external_static_optimizer(data_fixture, request):
data = request.getfixturevalue(data_fixture)
train_data, test_data = train_test_data_setup(data=data)

automl = Fedot(problem='classification', timeout=0.2, logging_level=logging.DEBUG,
automl = Fedot(problem='classification', timeout=0.1, logging_level=logging.DEBUG,
preset='fast_train',
with_tuning=False,
optimizer=partial(StaticOptimizer, node_name='logit'),
pop_size=2)
pop_size=2, cv_folds=None)
obtained_pipeline = automl.fit(train_data)
automl.predict(test_data)

Expand Down
Loading