🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
edit-baseline-experimenter
Cyzus Chi9abb8db95496
diff --git a/metagpt/ext/sela/experimenter/aide.py b/metagpt/ext/sela/experimenter/aide.pyindex fb71dbdab..50fae94c1 100644--- a/metagpt/ext/sela/experimenter/aide.py+++ b/metagpt/ext/sela/experimenter/aide.py@@ -1,11 +1,15 @@-import aideimport osimport time+import aide+os.environ["OPENAI_API_KEY"] = "sk-xxx"os.environ["OPENAI_BASE_URL"] = "your url"+start_time = time.time()+data_dir = "xxx/data/titanic"+goal = f"""# User requirement({data_dir}, 'This is a 04_titanic dataset. Your goal is to predict the target column `Survived`.\nPerform data analysis, data preprocessing, feature engineering, and modeling to predict the target. \nReport f1 on the eval data. Do not plot or make any visualizations.\n')@@ -28,4 +32,4 @@ print(f"Best solution code: {best_solution.code}")end_time = time.time()execution_time = end_time - start_time-print(f"run time : {execution_time} seconds")\ No newline at end of file+print(f"run time : {execution_time} seconds")diff --git a/metagpt/ext/sela/experimenter/autogluon.py b/metagpt/ext/sela/experimenter/autogluon.pyindex e7593cfb9..f547ce4ba 100644--- a/metagpt/ext/sela/experimenter/autogluon.py+++ b/metagpt/ext/sela/experimenter/autogluon.py@@ -1,8 +1,10 @@-from datetime import datetime-from metagpt.ext.sela.experimenter.custom import CustomExperimenterimport os+from datetime import datetime+import pandas as pd+from metagpt.ext.sela.experimenter.custom import CustomExperimenter+class AGRunner:def __init__(self, state=None):@@ -11,6 +13,7 @@ class AGRunner:def run(self):from autogluon.tabular import TabularDataset, TabularPredictor+train_path = self.datasets["train"]dev_path = self.datasets["dev"]dev_wo_target_path = self.datasets["dev_wo_target"]@@ -32,6 +35,7 @@ class AGRunner:def run_multimodal(self):from autogluon.multimodal import MultiModalPredictor+target_col = self.state["dataset_config"]["target_col"]train_path = self.datasets["train"]dev_path = self.datasets["dev"]@@ -56,10 +60,7 @@ class AGRunner:test_preds = predictor.predict(test_data)# Return predictions for dev and test datasets- return {- "dev_preds": dev_preds,- "test_preds": test_preds- }+ return {"dev_preds": dev_preds, "test_preds": test_preds}def load_split_dataset(self, train_path, dev_path, dev_wo_target_path, test_wo_target_path):"""@@ -94,7 +95,8 @@ class AGRunner:train_data[image_column] = train_data[image_column].apply(lambda x: os.path.join(root_folder, x))dev_data[image_column] = dev_data[image_column].apply(lambda x: os.path.join(root_folder, x))dev_wo_target_data[image_column] = dev_wo_target_data[image_column].apply(- lambda x: os.path.join(root_folder, x))+ lambda x: os.path.join(root_folder, x)+ )test_data[image_column] = test_data[image_column].apply(lambda x: os.path.join(root_folder, x))return train_data, dev_data, dev_wo_target_data, test_data@@ -106,7 +108,7 @@ class GluonExperimenter(CustomExperimenter):def __init__(self, args, **kwargs):super().__init__(args, **kwargs)self.framework = AGRunner(self.state)- self.is_multimodal = args.is_multimodal if hasattr(args, 'is_multimodal') else False+ self.is_multimodal = args.is_multimodal if hasattr(args, "is_multimodal") else Falseasync def run_experiment(self):if not self.is_multimodal:diff --git a/metagpt/ext/sela/experimenter/autosklearn.py b/metagpt/ext/sela/experimenter/autosklearn.pyindex 718e758d4..f6ff267e7 100644--- a/metagpt/ext/sela/experimenter/autosklearn.py+++ b/metagpt/ext/sela/experimenter/autosklearn.py@@ -1,8 +1,10 @@from datetime import datetime+from functools import partial+import pandas as pd-from metagpt.ext.sela.experimenter.custom import CustomExperimenter+from metagpt.ext.sela.evaluation.evaluation import evaluate_score-from functools import partial+from metagpt.ext.sela.experimenter.custom import CustomExperimenterdef custom_scorer(y_true, y_pred, metric_name):@@ -19,9 +21,7 @@ class ASRunner:def create_autosklearn_scorer(self, metric_name):from autosklearn.metrics import make_scorer- return make_scorer(- name=metric_name, score_func=partial(custom_scorer, metric_name=metric_name)- )+ return make_scorer(name=metric_name, score_func=partial(custom_scorer, metric_name=metric_name))def run(self):import autosklearn.classification