-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathautoml_autogluon.py
32 lines (21 loc) · 1.13 KB
/
automl_autogluon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import pandas as pd
from autogluon.tabular import TabularDataset, TabularPredictor
from common import *
if __name__ == "__main__":
for SEED in PRIME_NUMBERS:
try:
set_random_seed(SEED)
X_train, X_test, y_train, y_test = load_data_delegate(SEED)
train_df = pd.DataFrame(X_train).assign(**{'class': pd.Series(y_train)}).dropna()
test_df = pd.DataFrame(X_test).assign(**{'class': pd.Series(y_test)}).dropna()
clf = TabularPredictor(problem_type=infer_task_type(y_test), eval_metric='f1_weighted', label='class')
TIMER.tic()
clf = clf.fit(time_limit=EXEC_TIME_SECONDS, train_data=train_df, num_cpus=NUM_CPUS)
training_time = TIMER.tocvalue()
TIMER.tic()
y_test = test_df['class'].values
y_pred = clf.predict(test_df)
test_time = TIMER.tocvalue()
collect_and_persist_results(y_test, y_pred, training_time, test_time, "autogluon", SEED)
except Exception as e:
print(f'Cannot run autogluon for dataset {get_dataset_ref()} (seed={SEED}). Reason: {str(e)}')