I have build a custom estimator in sklearn, according to the documentation. Inside the fit method, I have a print statement, which I use for debugging. When I create an instance of this model and call the fit method, everything is working as expected. However, when calling cross_val_score, the statements are not printed anymore, although as far as I know, cross_val_score calls the fit method at each fold.
Is there any way to force the print statement inside cross-validation?
            Asked
            
        
        
            Active
            
        
            Viewed 219 times
        
    1
            
            
        
        desertnaut
        
- 57,590
 - 26
 - 140
 - 166
 
        Radu Gh
        
- 33
 - 3
 
- 
                    2Could parallel processing be swallowing the output? Try with n_jobs=1? – Ben Reiniger May 26 '20 at 20:50
 - 
                    @BenReiniger yes, that was indeed the case. Thank your for your answer. So, is there any way I could prevent parallel processing from doing so? – Radu Gh May 27 '20 at 21:48
 - 
                    are you running this in a Jupyter notebook, or ...? – Ben Reiniger May 28 '20 at 16:23
 - 
                    yes, in a Jupyter Notebook – Radu Gh May 29 '20 at 12:13
 
1 Answers
1
            Parallel processing in sklearn is handled by joblib.  When running cross_val_score with n_jobs != 1, evidently that doesn't play nicely with Jupyter output:
Printed output not displayed when using joblib in jupyter notebook
        Ben Reiniger
        
- 10,517
 - 3
 - 16
 - 29