mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-08 15:05:17 +02:00
edit-baseline-experimenter
This commit is contained in:
parent
61492d9ff5
commit
9abb8db954
3 changed files with 22 additions and 16 deletions
|
|
@ -1,11 +1,15 @@
|
|||
import aide
|
||||
import os
|
||||
import 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")
|
||||
print(f"run time : {execution_time} seconds")
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
from datetime import datetime
|
||||
from metagpt.ext.sela.experimenter.custom import CustomExperimenter
|
||||
import 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 False
|
||||
|
||||
async def run_experiment(self):
|
||||
if not self.is_multimodal:
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
from datetime import datetime
|
||||
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
|
||||
|
||||
import pandas as pd
|
||||
|
||||
from metagpt.ext.sela.evaluation.evaluation import evaluate_score
|
||||
from metagpt.ext.sela.experimenter.custom import CustomExperimenter
|
||||
|
||||
|
||||
def custom_scorer(y_true, y_pred, metric_name):
|
||||
return evaluate_score(y_pred, y_true, 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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue