Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use correclty pyprind with scikit-learn?

Tags:

Currently I am using pyprind, a library that implements a progress bar:

#Compute training time elapsed
pbar = pyprind.ProgBar(45, width=120, bar_char='█')
for _ in range(45):
    #Fiting
    clf = SVC().fit(X_train, y_train)
    pbar.update()
#End of bar

However, I do not know if that is the correct way to use the pbar, since I guess I am fitting 45 times clf. Thus, how should I use correctly pbar?.

like image 787
tumbleweed Avatar asked Jul 20 '16 06:07

tumbleweed


2 Answers

I haven't used pyprind but I have used progressbar. Just install it using-

pip install progressbar

And then -

from progressbar import ProgressBar
pbar = ProgressBar()
for x in pbar(range(45)):
    clf = SVC().fit(X_train, y_train)

and you are good to go.

like image 142
hashcode55 Avatar answered Sep 28 '22 01:09

hashcode55


Note that if you want more information regarding the learning process you can use vebose flag for that:

X = np.array([[-1, -1], [-2, -1], [1, 1], [2, 1]])
y = np.array([1, 1, 2, 2])
clf = SVC(verbose =True)
clf.fit(X, y)

Output:

optimization finished, #iter = 12
obj = -1.253423, rho = 0.000003
nSV = 4, nBSV = 0
Total nSV = 4
like image 24
Gal Dreiman Avatar answered Sep 28 '22 02:09

Gal Dreiman