Skip to content
This repository was archived by the owner on May 16, 2025. It is now read-only.

Commit 95bb17a

Browse files
committed
Update auto_sklearn.py
update the memory_limit with /os.cpu_count(), suggested in this issue: _pickle.UnpicklingError: pickle data was truncated #1215
1 parent 7763c39 commit 95bb17a

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

app/algorithms/auto_sklearn.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@
1010
from termcolor import colored
1111
import psutil
1212
import time
13+
import os
1314

1415

1516
def make_classification(X_train, X_test, y_train, y_test, timelife, y, time_start):
1617
# Classification model
1718
automl = autosklearn.classification.AutoSklearnClassifier(
18-
time_left_for_this_task=timelife*60,
19-
per_run_time_limit=30,
20-
memory_limit=int(int(psutil.virtual_memory().available * 1e-6) * 0.75),
21-
n_jobs=-1,
22-
resampling_strategy_arguments = {'cv': 10}
23-
)
19+
time_left_for_this_task=timelife*60,
20+
per_run_time_limit=30,
21+
memory_limit=int(int(psutil.virtual_memory().available * 1e-6) * 0.75)/os.cpu_count(),
22+
n_jobs=-1,
23+
resampling_strategy_arguments = {'cv': 10}
24+
)
2425
automl.fit(X_train, y_train)
2526
y_pred = automl.predict(X_test)
2627
pipelines = str(pd.DataFrame(pd.Series(automl.show_models())).iloc[0].squeeze()) # Pipeline
@@ -38,12 +39,12 @@ def make_classification(X_train, X_test, y_train, y_test, timelife, y, time_star
3839
def make_regression(X_train, X_test, y_train, y_test, timelife, time_start):
3940
# Regression model
4041
automl = autosklearn.regression.AutoSklearnRegressor(
41-
time_left_for_this_task=timelife*60,
42-
per_run_time_limit=30,
43-
memory_limit=int(int(psutil.virtual_memory().available * 1e-6) * 0.75),
44-
n_jobs=-1,
45-
resampling_strategy_arguments = {'cv': 10}
46-
)
42+
time_left_for_this_task=timelife*60,
43+
per_run_time_limit=30,
44+
memory_limit=int(int(psutil.virtual_memory().available * 1e-6) * 0.75)/os.cpu_count(),
45+
n_jobs=-1,
46+
resampling_strategy_arguments = {'cv': 10}
47+
)
4748
automl.fit(X_train, y_train)
4849
y_pred = automl.predict(X_test)
4950
pipelines = str(pd.DataFrame(pd.Series(automl.show_models())).iloc[0].squeeze().split('\n')) # Pipeline

0 commit comments

Comments
 (0)