简体   繁体   中英

How to use correclty pyprind with scikit-learn?

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 ?.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM