docs: some changes in kaggle doc (#461)

* add kaggle scenario description for webapp

* catch download button error

* change kaggle auto_submit to False default

* Added guidance for custom templates in kaggle doc

* CI

* CI

* add kaggle data set instruction(NOTE)

* delete repeated description for kaggle scenario

---------

Co-authored-by: TPLin22 <tplin2@163.com>
This commit is contained in:
XianBW
2024-10-30 17:00:56 +08:00
committed by GitHub
parent 80e4a2aa79
commit 2c206e9ce5
7 changed files with 66 additions and 14 deletions
+26
View File
@@ -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 <https://github.com/Kaggle/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
~~~~~~~~~~~
Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

+1 -1
View File
@@ -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
+10 -6
View File
@@ -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():
@@ -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:
+6 -4
View File
@@ -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": [
-2
View File
@@ -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]):