Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

fix import and update readme

limafangb49334b16c4c
diff --git a/expo/README.md b/expo/README.md
index e824312f2..707e6415e 100644
--- a/expo/README.md
+++ b/expo/README.md
@@ -183,10 +183,26 @@ pip install autogluon
提供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
diff --git a/expo/experimenter/autosklearn.py b/expo/experimenter/autosklearn.py
index 5786a3790..7340edafa 100644
--- a/expo/experimenter/autosklearn.py
+++ b/expo/experimenter/autosklearn.py
@@ -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"), # 使用新的函数创建评分器
- 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":
- automl = autosklearn.classification.AutoSklearnClassifier(
- time_left_for_this_task=self.time_limit,
- per_run_time_limit=60,
- metric=create_autosklearn_scorer("f1"), # 使用新的函数创建评分器
+ 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_weighted":
+ 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 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")