mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-11 15:15:18 +02:00
add input param for autogluon
This commit is contained in:
parent
e2cee3905f
commit
1a1855f21a
3 changed files with 25 additions and 13 deletions
|
|
@ -216,9 +216,19 @@ #### Setup
|
|||
pip install -U setuptools wheel
|
||||
pip install autogluon
|
||||
|
||||
python run_expriment.py --exp_mode autogluon --task fashion_mnist
|
||||
```
|
||||
|
||||
For Tabular data:
|
||||
```
|
||||
python run_expriment.py --exp_mode autogluon --task {task_name}
|
||||
```
|
||||
For Multimodal data:
|
||||
```
|
||||
python run_expriment.py --exp_mode autogluon --task {task_name} --is_multimodal
|
||||
```
|
||||
Replace {task_name} with the specific task you want to run.
|
||||
|
||||
|
||||
提供github链接,并说明使用的命令以及参数设置
|
||||
### AutoSklearn
|
||||
#### System requirements
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
from datetime import datetime
|
||||
|
||||
from expo.experimenter.custom import CustomExperimenter
|
||||
import os
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class AGRunner:
|
||||
preset = "best_quality"
|
||||
time_limit = 1000 # 1000s
|
||||
|
||||
def __init__(self, state=None):
|
||||
self.state = state
|
||||
self.datasets = self.state["datasets_dir"]
|
||||
|
|
@ -32,7 +30,7 @@ class AGRunner:
|
|||
test_preds = predictor.predict(test_data)
|
||||
return {"test_preds": test_preds, "dev_preds": dev_preds}
|
||||
|
||||
def run_images(self):
|
||||
def run_multimodal(self):
|
||||
from autogluon.multimodal import MultiModalPredictor
|
||||
target_col = self.state["dataset_config"]["target_col"]
|
||||
train_path = self.datasets["train"]
|
||||
|
|
@ -51,7 +49,7 @@ class AGRunner:
|
|||
label=target_col,
|
||||
eval_metric=eval_metric,
|
||||
path="AutogluonModels/ag-{}-{}".format(self.state["task"], datetime.now().strftime("%y%m%d_%H%M")),
|
||||
).fit(train_data=train_data, tuning_data=dev_data, time_limit=self.time_limit)
|
||||
).fit(train_data=train_data, tuning_data=dev_data)
|
||||
|
||||
# Make predictions on dev and test datasets
|
||||
dev_preds = predictor.predict(dev_wo_target_data)
|
||||
|
|
@ -64,8 +62,6 @@ class AGRunner:
|
|||
}
|
||||
|
||||
def load_split_dataset(self, train_path, dev_path, dev_wo_target_path, test_wo_target_path):
|
||||
import os
|
||||
import pandas as pd
|
||||
"""
|
||||
Loads training, dev, and test datasets from given file paths
|
||||
|
||||
|
|
@ -91,16 +87,16 @@ class AGRunner:
|
|||
dev_wo_target_data = pd.read_csv(dev_wo_target_path) # Load dev dataset without target labels
|
||||
test_data = pd.read_csv(test_wo_target_path)
|
||||
|
||||
|
||||
# Get the name of the first column (assuming it's the image path column)
|
||||
|
||||
image_column = train_data.columns[0]
|
||||
|
||||
# Append root folder path to the image column in each dataset
|
||||
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))
|
||||
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
|
||||
|
||||
|
||||
|
|
@ -110,10 +106,15 @@ 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
|
||||
|
||||
async def run_experiment(self):
|
||||
# result = self.framework.run()
|
||||
result = self.framework.run_images()
|
||||
if not self.is_multimodal:
|
||||
result = self.framework.run()
|
||||
else:
|
||||
result = self.framework.run_multimodal()
|
||||
|
||||
assert result is not None
|
||||
user_requirement = self.state["requirement"]
|
||||
dev_preds = result["dev_preds"]
|
||||
test_preds = result["test_preds"]
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ def get_mcts_args(parser):
|
|||
|
||||
def get_aug_exp_args(parser):
|
||||
parser.add_argument("--aug_mode", type=str, default="single", choices=["single", "set"])
|
||||
parser.add_argument("--is_multimodal", action="store_true", help="Specify if the model is multi-modal")
|
||||
|
||||
|
||||
def get_di_args(parser):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue