Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A progress bar for scikit-learn?

Tags:

scikit-learn

If you initialize the model with verbose=1 before calling fit you should get some kind of output indicating the progress.

For example sklearn.ensemble.GradientBoostingClassifer(verbose=1) provides progress output that looks like this:

  Iter       Train Loss   Remaining Time
     1           1.2811            0.71s
     2           1.2595            0.58s
     3           1.2402            0.50s
     4           1.2263            0.46s
     5           1.2121            0.43s
     6           1.1999            0.41s
     7           1.1876            0.39s
     8           1.1761            0.38s
     9           1.1673            0.37s
    10           1.1591            0.36s
    20           1.1021            0.29s
    30           1.0511            0.27s
    40           1.0116            0.25s
    50           0.9830            0.22s
    60           0.9581            0.19s
    70           0.9377            0.16s
    80           0.9169            0.14s
    90           0.9049            0.12s
   100           0.8973            0.10s

Many models support a verbose argument which gives progress (and sometimes an indication on the rate of convergence).

e.g.

clf = MLPClassifier(verbose=True)

(see MLPClassifier )

If you have a loop outside of the learning model, I recommend tqdm.


Not all scikit-learn models support the verbose parameter

Unfortunately not all scikit-learn models allow the verbose parameter. Off the top of my head I can say these models do not allow verbose parameter (there may be more):

  • AdaBoostClassifier
  • DecisionTreeClassifier
  • OneVsRestClassifier

Yet curiously ExtraTreesClassifier which also belongs to sklearn.ensemble (just like AdaBoostClassifier), does allow it.

Looks like not all members of sklearn.ensemble share the same base properties.