Exception : RecursionError on Introductory example to ensemble models

Hi,

I am trying to run the Introductory example to ensemble models notebook on my local computer.
I got the following exception : RecursionError…PicklingError: Could not pickle object as excessively deep recursion required.

I looked at the sys limitrecursion and I have the same 3000 limit as in your Sandbook in the Cloud.

I don’t how to handle this exception even when I’m looking on stackoverflow.

Can you help me to understand what’s going on ?

PS : my computer : Windows 7 Entreprise 64 BIT
intel-core i5-3570 CPU 3.40
RAM: 16 GO

Can you post the snippet of code that triggers this error? Usually, it means that you have a recursive function call (a function that calls itself up to infinity). The PicklingError makes me think that you do that in parallel. But without a code snippet, this is difficult to know.

Hello,
I ran the very same code :

from sklearn.model_selection import cross_validate
from sklearn.tree import DecisionTreeRegressor

tree = DecisionTreeRegressor(random_state=0)
cv_results = cross_validate(tree, data, target, n_jobs=2)
scores = cv_results["test_score"]

print(f"R2 score obtained by cross-validation: "
      f"{scores.mean():.3f} +/- {scores.std():.3f}")

Here is the screenshot of the exception I got




It looks like a joblib issue. @ogrisel do you have any idea? From the following issue (Can't use with temporary directories on Windows · Issue #1365 · joblib/joblib · GitHub) it seems that deleting a temporary folder in windows would trigger this error but I don’t think that we do that internally.

@MAmazigh for future reference, can you post the output of:

import sklearn; sklearn.show_versions()

Also if possible, please don’t post screenshots (you can not search them and they are hard to read) but copy and paste the text output :pray:

1 Like

Hi,

Here is the output from import sklearn; sklearn.show_versions() on my computer

System:
python: 3.7.0 (default, Jun 28 2018, 08:04:48) [MSC v.1912 64 bit (AMD64)]
executable: C:\ProgramData\Anaconda3\python.exe
machine: Windows-7-6.1.7601-SP1

Python dependencies:
pip: 22.3.1
setuptools: 40.2.0
sklearn: 1.0.2
numpy: 1.21.6
scipy: 1.7.3
Cython: 0.28.5
pandas: 1.1.5
matplotlib: 2.2.3
joblib: 1.1.0
threadpoolctl: 3.1.0

Built with OpenMP: True

Thanks, if that’s not too much work, you may want to try if you have the same issue with Python 3.8.