-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BrokenPipeError: [Errno 32] when using custom loss_fn #144
Comments
I haven't been able to reproduce this error. Can you provide more info on the classifier you are using and the type of data? Is it correct to assume the
This can be fixed by setting Here is a simple full script that I made to try to reproduce it. I get no error on my end when I run this, is that the same for you? What do you need to change to see the broken pipe? from hpsklearn import HyperoptEstimator, any_preprocessing, any_classifier
from hyperopt import tpe
from sklearn.metrics import f1_score
# picking an easily available dataset for binary classification
from sklearn.datasets import load_breast_cancer
data = load_breast_cancer()
X_train = data.data
y_train = data.target
def f1_loss(target, pred):
return -f1_score(target, pred)
clf = any_classifier('clf')
estim = HyperoptEstimator(classifier=clf,
preprocessing=any_preprocessing('my_pre'),
algo=tpe.suggest,
max_evals=10,
trial_timeout=120,
loss_fn=f1_loss,
)
estim.fit(X_train, y_train)
print(estim.score(X_train, y_train))
print(estim.best_model()) |
Hi ! Thank you for your answer. My configuration : Windows10, Anaconda, Python 3.7.5, JupyterLab 1.1.4, scikit-learn 0.21.3 Here is the full Traceback :
|
This helps a ton! I've been testing with linux. From searching around it looks like this broken pipe error is a very common issue with multiprocessing in Python and with Windows. One common solution people have is to wrap your code in an So something like this: def main():
# your code here
if __name__ == '__main__':
main() This doesn't always work, and some people have resorted to disabling multiprocessing for windows. Unfortunately there doesn't seem to be a flag for that in hyperopt-sklearn at the moment. |
Thank you for your help.
|
I'm getting similar error using a custom f2 loss.
The full trace:
|
def f1_loss(target, pred):
return -f1_score(target, pred)
Instantiate a HyperoptEstimator with the search space and number of evaluations
estim = HyperoptEstimator(classifier=clf,
preprocessing=any_preprocessing('my_pre'),
algo=tpe.suggest,
max_evals=10,
trial_timeout=120,
loss_fn=f1_loss,
)
Search the hyperparameter space based on the data
estim.fit(X_train, y_train)
Get this error :
BrokenPipeError Traceback (most recent call last)
in
55
56 # Search the hyperparameter space based on the data
---> 57 estim.fit(X_train, y_train)
[…]
BrokenPipeError: [Errno 32] Broken pipe
The text was updated successfully, but these errors were encountered: