mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-11 15:15:18 +02:00
fix import and update readme
This commit is contained in:
parent
9ba9371656
commit
b49334b16c
2 changed files with 29 additions and 21 deletions
|
|
@ -183,10 +183,26 @@ #### Setup
|
|||
|
||||
提供github链接,并说明使用的命令以及参数设置
|
||||
### AutoSklearn
|
||||
#### System requirements
|
||||
auto-sklearn has the following system requirements:
|
||||
|
||||
- Linux operating system (for example Ubuntu)
|
||||
|
||||
- Python (>=3.7)
|
||||
|
||||
- C++ compiler (with C++11 supports)
|
||||
|
||||
In case you try to install Auto-sklearn on a system where no wheel files for the pyrfr package are provided (see here for available wheels) you also need:
|
||||
|
||||
- SWIG [(get SWIG here).](https://www.swig.org/survey.html)
|
||||
|
||||
For an explanation of missing Microsoft Windows and macOS support please check the Section [Windows/macOS compatibility](https://automl.github.io/auto-sklearn/master/installation.html#windows-macos-compatibility).
|
||||
|
||||
#### Setup
|
||||
```
|
||||
pip install autosklearn
|
||||
pip install auto-sklearn
|
||||
```
|
||||
|
||||
#### Run
|
||||
```
|
||||
python run_experiment.py --exp_mode autosklearn --task titanic
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
from datetime import datetime
|
||||
import autosklearn.classification
|
||||
import autosklearn.regression
|
||||
import pandas as pd
|
||||
from expo.experimenter.custom import CustomExperimenter
|
||||
from expo.evaluation.evaluation import evaluate_score
|
||||
from autosklearn.metrics import make_scorer
|
||||
from functools import partial
|
||||
|
||||
|
||||
|
|
@ -24,6 +21,14 @@ class ASRunner:
|
|||
def __init__(self, state=None):
|
||||
self.state = state
|
||||
self.datasets = self.state["datasets_dir"]
|
||||
try:
|
||||
import autosklearn.classification
|
||||
import autosklearn.regression
|
||||
from autosklearn.metrics import make_scorer
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
"autosklearn not found or system not supported, please check it first"
|
||||
)
|
||||
|
||||
def run(self):
|
||||
train_path = self.datasets["train"]
|
||||
|
|
@ -34,7 +39,7 @@ class ASRunner:
|
|||
train_data = pd.read_csv(train_path)
|
||||
dev_data = pd.read_csv(dev_wo_target_path)
|
||||
test_data = pd.read_csv(test_wo_target_path)
|
||||
eval_metric = self.state["dataset_config"]["metric"].replace(" ", "_")
|
||||
eval_metric = self.state["dataset_config"]["metric"]
|
||||
X_train = train_data.drop(columns=[target_col])
|
||||
y_train = train_data[target_col]
|
||||
|
||||
|
|
@ -42,31 +47,18 @@ class ASRunner:
|
|||
automl = autosklearn.regression.AutoSklearnRegressor(
|
||||
time_left_for_this_task=self.time_limit,
|
||||
per_run_time_limit=60,
|
||||
metric=create_autosklearn_scorer("rmse"), # 使用新的函数创建评分器
|
||||
metric=create_autosklearn_scorer(eval_metric),
|
||||
memory_limit=8192,
|
||||
tmp_folder="AutosklearnModels/as-{}-{}".format(
|
||||
self.state["task"], datetime.now().strftime("%y%m%d_%H%M")
|
||||
),
|
||||
n_jobs=-1,
|
||||
)
|
||||
elif eval_metric == "f1":
|
||||
elif eval_metric in ["f1", "f1 weighted"]:
|
||||
automl = autosklearn.classification.AutoSklearnClassifier(
|
||||
time_left_for_this_task=self.time_limit,
|
||||
per_run_time_limit=60,
|
||||
metric=create_autosklearn_scorer("f1"), # 使用新的函数创建评分器
|
||||
memory_limit=8192,
|
||||
tmp_folder="AutosklearnModels/as-{}-{}".format(
|
||||
self.state["task"], datetime.now().strftime("%y%m%d_%H%M")
|
||||
),
|
||||
n_jobs=-1,
|
||||
)
|
||||
elif eval_metric == "f1_weighted":
|
||||
automl = autosklearn.classification.AutoSklearnClassifier(
|
||||
time_left_for_this_task=self.time_limit,
|
||||
per_run_time_limit=60,
|
||||
metric=create_autosklearn_scorer(
|
||||
"f1 weighted"
|
||||
), # 使用新的函数创建评分器
|
||||
metric=create_autosklearn_scorer(eval_metric),
|
||||
memory_limit=8192,
|
||||
tmp_folder="AutosklearnModels/as-{}-{}".format(
|
||||
self.state["task"], datetime.now().strftime("%y%m%d_%H%M")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue