rasbt / python-machine-learning-book

The "Python Machine Learning (1st edition)" book code repository and info resource
MIT License
12.24k stars 4.4k forks source link

ch.06(Tuning hyperparameters via grid search) #71

Open yuusukekoyano opened 6 years ago

yuusukekoyano commented 6 years ago

I'm now learning machine learning using the Japanese translation of this book, and when I run this program, I always get stuck on the part using sklearn.svm.

When the program do the part"gs=gs.fit(X_train,y_train)", it always show the past two graphs infinitely. I don't know the reason, so tell me what may be the cause.

My PC's spec: Window10, python3.6.5, scikit-learn0.19.1

rasbt commented 6 years ago

Hi there,

with "infinitely," you mean that the graphs from the previously executed code are still shown and don't go away?

In Python, you usually need to close the plot manually if you are executing the code from the interactive Python interpreter or via a Python script (.py file). Usually, you see a window on your screen somewhere, and you can then close it by clicking on the "window close" button (I think this is similar to macOS & Linux in Windows, i.e., a small "x" button in the left or right top corner).

yuusukekoyano commented 6 years ago

Thank you, master, for the reply, and sorry for responding late. And I'm sorry I had to tell the further detail.

I implemented the whole code in ch.06, and when doing that part, first, the program shows four graphs, actually the learning curve it showed before. When closing any of them, then it shows another graph, also actually the validation curve. Finally when closing it, shows the learning curve, and goes back to first: I meant this as “infinitely.”

So that is the detail. Please tell me some of what may be the cause.

rasbt commented 6 years ago

Hi there,

I am not sure why this is happening. My guess is that you may have run the plotting code multiple times before closing the current plot, and after you close it the previous plots show up. My guess it's not really "infinitely" but rather a certain number of times given how often you executed the code before.

Other than that, maybe try to change the backend that is used by matplotlib to create the plots. I have never used Windows 10 before, so I can't help you with the details here, but I found some Stackoverflow that might be helpful: https://stackoverflow.com/questions/40747104/set-matplotlib-backend-when-using-windows-subsystem-for-linux

yuusukekoyano commented 6 years ago

Thank you, I'll try it.