amueller / introduction_to_ml_with_python

Notebooks and code for the book "Introduction to Machine Learning with Python"
7.44k stars 4.56k forks source link

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

Open JorgeFBock opened 1 year ago

JorgeFBock commented 1 year ago

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
wanghedy commented 1 year ago

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

buyanahr commented 7 months ago

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.

wanghedy commented 3 months ago

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

SirBaoguoMa commented 3 months ago

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