diff --git a/docs/scens/kaggle_agent.rst b/docs/scens/kaggle_agent.rst index 272b2055..bea1e676 100644 --- a/docs/scens/kaggle_agent.rst +++ b/docs/scens/kaggle_agent.rst @@ -100,6 +100,10 @@ You can try our demo by running the following command: The `competition name` parameter must match the name used with the API on the Kaggle platform. +(NOTE: The code for crawling Kaggle competition information may not be applicable to your environment. + +If you cannot execute it normally, you can refer to the following **Example Guide: Running a Specific Experiment**.) + 📋 Competition List Available ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -149,6 +153,8 @@ You can try our demo by running the following command: - Alternatively, you can manually place the dataset in the specified location in advance. + - you can download the kaggle_data.zip in the release and unzip it to the directory configured by the `KG_LOCAL_DATA_PATH` environment variable. + - 🚀 **Run the Application** @@ -166,6 +172,26 @@ You can try our demo by running the following command: For more information about Kaggle API Settings, refer to the `Kaggle API `_. + +🎨 Customize one template for a new competition +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +In order to facilitate RD-Agent to generate competition codes, we have specified a competition code structure: + +.. image:: kaggle_template.png + :alt: Design of Kaggle Code Template + :align: center + +- **feature directory** contains the feature engineering code. Generally no modification is required. +- **model directory** contains the model codes. + select_xx.py is used to select different features according to different models. + model_xx.py is the basic code of different models. Generally, only some initial parameters need to be adjusted. +- **fea_share_preprocess.py** is some basic preprocessing code shared by different models. The degree of customization here is high, but the preprocess_script() function needs to be retained, which will be called by train.py +- **train.py** is the main code, which connects all the codes and is also the code called during the final execution. + +**We will soon provide a tool for automatic/semi-automatic template generation.** +If you want to try a different competition now, you can refer to our current template structure and content to write a new template. + + 🎯 Roadmap ~~~~~~~~~~~ diff --git a/docs/scens/kaggle_template.png b/docs/scens/kaggle_template.png new file mode 100644 index 00000000..022c8920 Binary files /dev/null and b/docs/scens/kaggle_template.png differ diff --git a/rdagent/app/kaggle/conf.py b/rdagent/app/kaggle/conf.py index c9b1195c..13a4d5db 100644 --- a/rdagent/app/kaggle/conf.py +++ b/rdagent/app/kaggle/conf.py @@ -69,7 +69,7 @@ class KaggleBasePropSetting(BasePropSetting): knowledge_base_path: str = "kg_graph.pkl" """Advanced version of graph-based RAG""" - auto_submit: bool = True + auto_submit: bool = False """Automatically upload and submit each experiment result to Kaggle platform""" mini_case: bool = False diff --git a/rdagent/log/ui/app.py b/rdagent/log/ui/app.py index 2e1d65dd..ddc0c837 100644 --- a/rdagent/log/ui/app.py +++ b/rdagent/log/ui/app.py @@ -560,12 +560,16 @@ def feedback_window(): st.markdown( f":green[**Exp Workspace**]: {str(fbe[0].content.experiment_workspace.workspace_path.absolute())}" ) - st.download_button( - label="**Download** submission.csv", - data=submission_path.read_bytes(), - file_name="submission.csv", - mime="text/csv", - ) + try: + data = submission_path.read_bytes() + st.download_button( + label="**Download** submission.csv", + data=data, + file_name="submission.csv", + mime="text/csv", + ) + except Exception as e: + st.markdown(f":red[**Download Button Error**]: {e}") def evolving_window(): diff --git a/rdagent/scenarios/kaggle/experiment/scenario.py b/rdagent/scenarios/kaggle/experiment/scenario.py index 2e32edf7..76a0dab2 100644 --- a/rdagent/scenarios/kaggle/experiment/scenario.py +++ b/rdagent/scenarios/kaggle/experiment/scenario.py @@ -221,7 +221,29 @@ The model code should follow the simulator: @property def rich_style_description(self) -> str: return f""" -This is the Kaggle scenario for the competition: {self.competition} +### Kaggle Agent: Automated Feature Engineering & Model Tuning Evolution + +#### [Overview](#_summary) + +In this scenario, our automated system proposes hypothesis, choose action, implements code, conducts validation, and utilizes feedback in a continuous, iterative process. + +#### Kaggle Competition info + +Current Competition: [{self.competition}](https://www.kaggle.com/competitions/{self.competition}) + +#### [Automated R&D](#_rdloops) + +- **[R (Research)](#_research)** +- Iteration of ideas and hypotheses. +- Continuous learning and knowledge construction. + +- **[D (Development)](#_development)** +- Evolving code generation, model refinement, and features generation. +- Automated implementation and testing of models/features. + +#### [Objective](#_summary) + +To automatically optimize performance metrics within the validation set or Kaggle Leaderboard, ultimately discovering the most efficient features and models through autonomous research and development. """ def get_scenario_all_desc(self, task: Task | None = None) -> str: diff --git a/rdagent/scenarios/kaggle/kaggle_crawler.py b/rdagent/scenarios/kaggle/kaggle_crawler.py index b9201d98..38ec0947 100644 --- a/rdagent/scenarios/kaggle/kaggle_crawler.py +++ b/rdagent/scenarios/kaggle/kaggle_crawler.py @@ -96,7 +96,7 @@ def crawl_descriptions(competition: str, wait: float = 3.0, force: bool = False) return descriptions -def download_data(competition: str, local_path: str = "/data/userdata/share/kaggle") -> None: +def download_data(competition: str, local_path: str = KAGGLE_IMPLEMENT_SETTING.local_data_path) -> None: data_path = f"{local_path}/{competition}" if not Path(data_path).exists(): subprocess.run(["kaggle", "competitions", "download", "-c", competition, "-p", data_path]) @@ -136,7 +136,7 @@ def score_rank(competition: str, score: float) -> tuple[int, float]: def download_notebooks( - competition: str, local_path: str = "/data/userdata/share/kaggle/notebooks", num: int = 15 + competition: str, local_path: str = f"{KAGGLE_IMPLEMENT_SETTING.local_data_path}/notebooks", num: int = 15 ) -> None: data_path = Path(f"{local_path}/{competition}") from kaggle.api.kaggle_api_extended import KaggleApi @@ -183,7 +183,9 @@ def notebook_to_knowledge(notebook_text: str) -> str: return response -def convert_notebooks_to_text(competition: str, local_path: str = "/data/userdata/share/kaggle/notebooks") -> None: +def convert_notebooks_to_text( + competition: str, local_path: str = f"{KAGGLE_IMPLEMENT_SETTING.local_data_path}/notebooks" +) -> None: data_path = Path(f"{local_path}/{competition}") converted_num = 0 @@ -219,7 +221,7 @@ def convert_notebooks_to_text(competition: str, local_path: str = "/data/userdat print(f"Converted {converted_num} notebooks to text files.") -def collect_knowledge_texts(local_path: str = "/data/userdata/share/kaggle") -> dict[str, list[str]]: +def collect_knowledge_texts(local_path: str = KAGGLE_IMPLEMENT_SETTING.local_data_path) -> dict[str, list[str]]: """ { "competition1": [ diff --git a/rdagent/utils/env.py b/rdagent/utils/env.py index 64f16b52..d3104994 100644 --- a/rdagent/utils/env.py +++ b/rdagent/utils/env.py @@ -186,8 +186,6 @@ class KGDockerConf(DockerConf): # Path("git_ignore_folder/data").resolve(): "/root/.data/" # } - # local_data_path: str = "/data/userdata/share/kaggle" - # physionet.org/files/mimic-eicu-fiddle-feature/1.0.0/FIDDLE_mimic3 class DockerEnv(Env[DockerConf]):