Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
8 changes: 7 additions & 1 deletion rdagent/app/kaggle/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ class KaggleBasePropSetting(ExtendedBaseSettings):
"""Enable mini-case study for experiments"""

time_ratio_limit_to_enable_hyperparameter_tuning: float = 1
"""Time ratio limit to enable hyperparameter tuning, if not change, hyperparameter tuning is always enabled in the first evolution."""
"""Runner time ratio limit to enable hyperparameter tuning, if not change, hyperparameter tuning is always enabled in the first evolution."""

res_time_ratio_limit_to_enable_hyperparameter_tuning: float = 1
"""Overall rest time ratio limit to enable hyperparameter tuning, if not change, hyperparameter tuning is always enabled in the first evolution."""

only_enable_tuning_in_merge: bool = False
"""Enable hyperparameter tuning only in the merge stage"""


KAGGLE_IMPLEMENT_SETTING = KaggleBasePropSetting()
30 changes: 23 additions & 7 deletions rdagent/scenarios/data_science/dev/runner/eval.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import re
from dataclasses import dataclass
from datetime import timedelta
from pathlib import Path

import pandas as pd
Expand All @@ -15,6 +16,7 @@
from rdagent.core.evolving_framework import QueriedKnowledge
from rdagent.core.experiment import FBWorkspace, Task
from rdagent.log import rdagent_logger as logger
from rdagent.log.timer import RD_Agent_TIMER_wrapper
from rdagent.scenarios.data_science.test_eval import (
MLETestEval,
NoTestEvalError,
Expand Down Expand Up @@ -160,14 +162,28 @@ def evaluate(
submission_check_out, submission_ret_code = test_eval.valid(self.scen.competition, implementation)
stdout += f"\n### Submission check:\n{submission_check_out}\nIf Submission check returns a 'Submission is valid' or similar message, despite some warning messages, you should still consider the submission as valid and give a positive final decision. "

# Whether to enable hyperparameter tuning check
# 1. This is the first loop of evaluation.
c1 = len(queried_knowledge.task_to_former_failed_traces[target_task.get_task_information()][0]) == 0

# 2. The current time spent on runner is less than the time limit ratio for runner timeout.
time_spent_ratio = implementation.running_info.running_time / env.conf.running_timeout_period
# Only enable hyperparameter tuning on the first evaluation.
# Avoid too much time consuming.
enable_hyperparameter_tuning_check = False
if len(queried_knowledge.task_to_former_failed_traces[target_task.get_task_information()][0]) == 0 and (
time_spent_ratio < DS_RD_SETTING.time_ratio_limit_to_enable_hyperparameter_tuning
):
enable_hyperparameter_tuning_check = True
c2 = time_spent_ratio < DS_RD_SETTING.time_ratio_limit_to_enable_hyperparameter_tuning

# 3. Only enable hyperparameter tuning during the merge stage if configured.
timer = RD_Agent_TIMER_wrapper.timer
Comment thread
RolandMinrui marked this conversation as resolved.
res_time = timer.remain_time()
if DS_RD_SETTING.only_enable_tuning_in_merge:
c3 = res_time <= timedelta(hours=DS_RD_SETTING.merge_hours)
else:
c3 = True

# 4. The current time spent on global is less than the time limit ratio for whole timeout.
res_ratio = res_time / timer.all_duration
c4 = res_ratio <= DS_RD_SETTING.res_time_ratio_limit_to_enable_hyperparameter_tuning

# Only enable hyperparameter tuning check if all conditions are met
enable_hyperparameter_tuning_check = c1 and c2 and c3 and c4

system_prompt = T(".prompts:DSCoSTEER_eval.system").r(
scenario=self.scen.get_scenario_all_desc(eda_output=implementation.file_dict.get("EDA.md", None)),
Expand Down