"RuntimeError: main thread is not in main loop" when training multiple sklearn classifiers #11882
Unanswered
lise-brinck
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am experiencing an error that I don't understand and I don't understand why my fix works.
I am training multiple sklearn classifiers with different feature sets and tracking them all as child runs of a parent run.
feature_sets
is a list of lists of features,List[List[str]]
.get_data_from_df()
returns a tuple of apd.DataFrame
with only the features fromfeature_set
and apd.Series
.load_testset()
loads apd.DataFrame
from a path to a csv-file and adds features from the classifier.score_models()
returns a dict with different metrics, i.e., precision, accuracy etc.It works fine with just one classifier, but when it gets to the second one, I get the following error:
It seems, the error occurs becasue of
mlflow.log_metrics()
and as far as I can tell, it has to do with matplotlib.This Stackoverflow thread lead me to the solution of setting the backend for matplotlib. I don't understand why this solves it.
Furthermore, it seems simply importing matplotlib into the Python script that I'm running the training from also works. Even without setting the backend for matplotlib. This, I don't understand at all.
Can anyone enlighten me on why the error occurs and why importing matplotlib solves it?
Beta Was this translation helpful? Give feedback.
All reactions