introduction_to_ml_with_python icon indicating copy to clipboard operation
introduction_to_ml_with_python copied to clipboard

mglearn.plots.plot_pca_faces(X_train, X_test, image_shape)

Open JorgeFBock opened this issue 1 year ago • 4 comments

I just get 5x3 very black images with nothing but black. All codes prior to this line run smoothly and no problem Is there any hint as to why and how to fix it? I m using "noteable". Python 3.9.

The next lines, run perfectly and the graph is as in the book: mglearn.discrete_scatter(X_train_pca[:, 0], X_train_pca[:, 1], y_train) plt.xlabel("First principal component") plt.ylabel("Second principal component")

BR

Screenshot 2023-09-27 104601

JorgeFBock avatar Sep 27 '23 13:09 JorgeFBock

您的邮件已收到,我将会尽快处理,谢谢。王宇凝

wanghedy avatar Sep 27 '23 13:09 wanghedy

Hello, I successfully solved the problem.You can find mglearn/plot_pca.py.There is a function named plot_pca_faces:

def plot_pca_faces(X_train, X_test, image_shape):
    --snip--

The imshow function is called in this function,You can set vmax=255,or directly delete vminandvmax. After that the image will be displayed normally.

buyanahr avatar Mar 24 '24 09:03 buyanahr

您的邮件已收到,我将会尽快处理,谢谢。王宇凝

wanghedy avatar Aug 01 '24 07:08 wanghedy

Hello, I successfully solved the problem.You can find mglearn/plot_pca.py.There is a function named plot_pca_faces:

def plot_pca_faces(X_train, X_test, image_shape):
    --snip--

The imshow function is called in this function,You can set vmax=255,or directly delete vminandvmax. After that the image will be displayed normally.

Deleting vmin and vmax will do the trick, thanks

SirBaoguoMa avatar Aug 03 '24 11:08 SirBaoguoMa