From cade50de8940f298c9424c726e3fb1ced730d74d Mon Sep 17 00:00:00 2001 From: you-n-g Date: Wed, 5 Feb 2025 10:21:53 +0800 Subject: [PATCH] fix: handle division by zero in percentage calculations (#550) * fix: Handle division by zero in percentage calculations * lint --- rdagent/app/cli.py | 2 +- rdagent/components/coder/data_science/model/eval.py | 2 +- .../components/coder/data_science/raw_data_loader/__init__.py | 4 ++-- rdagent/core/proposal.py | 4 +--- rdagent/log/ui/dsapp.py | 4 ++-- .../new-york-city-taxi-fare-prediction/model/model_linear.py | 2 +- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/rdagent/app/cli.py b/rdagent/app/cli.py index 31f7703e..75569f1b 100644 --- a/rdagent/app/cli.py +++ b/rdagent/app/cli.py @@ -1,7 +1,7 @@ """ CLI entrance for all rdagent application. -This will +This will - make rdagent a nice entry and - autoamtically load dotenv """ diff --git a/rdagent/components/coder/data_science/model/eval.py b/rdagent/components/coder/data_science/model/eval.py index aa10d662..6acd7fa3 100644 --- a/rdagent/components/coder/data_science/model/eval.py +++ b/rdagent/components/coder/data_science/model/eval.py @@ -1,6 +1,6 @@ """ Beyond previous tests -- +- """ import json diff --git a/rdagent/components/coder/data_science/raw_data_loader/__init__.py b/rdagent/components/coder/data_science/raw_data_loader/__init__.py index fbd26a19..2f481b00 100644 --- a/rdagent/components/coder/data_science/raw_data_loader/__init__.py +++ b/rdagent/components/coder/data_science/raw_data_loader/__init__.py @@ -3,8 +3,8 @@ Loop should not large change exclude - Action Choice[current data loader & spec] - other should share - - Propose[choice] => Task[Choice] => CoSTEER => - - + - Propose[choice] => Task[Choice] => CoSTEER => + - Extra feature: - cache diff --git a/rdagent/core/proposal.py b/rdagent/core/proposal.py index 0739dc82..d102d9d4 100644 --- a/rdagent/core/proposal.py +++ b/rdagent/core/proposal.py @@ -1,6 +1,4 @@ -""" - -""" +""" """ from __future__ import annotations diff --git a/rdagent/log/ui/dsapp.py b/rdagent/log/ui/dsapp.py index 868a9a0a..09e7ae88 100644 --- a/rdagent/log/ui/dsapp.py +++ b/rdagent/log/ui/dsapp.py @@ -270,10 +270,10 @@ def all_summarize_win(): base_df.loc[k, "Competition"] = v["competition"] base_df.loc[k, "Total Loops"] = loop_num base_df.loc[k, "Made Submission"] = ( - f"{v['made_submission_num']} ({round(v['made_submission_num'] / loop_num * 100, 2)}%)" + f"{v['made_submission_num']} ({round(v['made_submission_num'] / loop_num * 100, 2) if loop_num != 0 else 0}%)" ) base_df.loc[k, "Successful Final Decision"] = ( - f"{v['success_loop_num']} ({round(v['success_loop_num'] / loop_num * 100, 2)}%)" + f"{v['success_loop_num']} ({round(v['success_loop_num'] / loop_num * 100, 2) if loop_num != 0 else 0}%)" ) base_df.loc[k, "Medal"] = v["medal"] st.dataframe(base_df) diff --git a/rdagent/scenarios/kaggle/experiment/templates/new-york-city-taxi-fare-prediction/model/model_linear.py b/rdagent/scenarios/kaggle/experiment/templates/new-york-city-taxi-fare-prediction/model/model_linear.py index 3980853e..a9fedbc6 100644 --- a/rdagent/scenarios/kaggle/experiment/templates/new-york-city-taxi-fare-prediction/model/model_linear.py +++ b/rdagent/scenarios/kaggle/experiment/templates/new-york-city-taxi-fare-prediction/model/model_linear.py @@ -1,7 +1,7 @@ """ Motivation of the model: The Linear Regression model is chosen for its simplicity and interpretability. It is a good starting point for regression tasks -and provides a baseline to compare more complex models against. Linear Regression assumes a linear relationship between the +and provides a baseline to compare more complex models against. Linear Regression assumes a linear relationship between the features and the target variable, which can be a reasonable assumption for many problems. """