Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PCA visualizer is not rendering 3D plot #984

Closed
Kautumn06 opened this issue Oct 20, 2019 · 2 comments
Closed

PCA visualizer is not rendering 3D plot #984

Kautumn06 opened this issue Oct 20, 2019 · 2 comments
Assignees

Comments

@Kautumn06
Copy link
Contributor

The PCADecomposition visualizer should generate a 3D plot when passed proj_dim=3; however, it currently needs to be explicitly passed a matplotlib 3D axis in order to render correctly. For instance, the following code will return a 2D plot despite the proj_dim parameter being set to 3.

from yellowbrick.datasets import load_credit
from yellowbrick.features import PCADecomposition

X, y = load_credit()

visualizer = PCADecomposition(scale=True, proj_dim=3)
visualizer.fit_transform(X, y)
visualizer.show()

pca-2

However, a 3D plot will be returned when explicitly passed a 3D axis, as in this example:

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

from yellowbrick.datasets import load_credit
from yellowbrick.features import PCADecomposition

X, y = load_credit()

# Create a figure and add a 3D axis
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

visualizer = PCADecomposition(scale=True, proj_dim=3, ax=ax)
visualizer.fit_transform(X, y)
visualizer.show()

pca-3D

@naresh-bachwani
Copy link
Contributor

Hey there @Kautumn06,
We changed the proj_dim parameter to projection in #908. Try using projection! :)

@pdamodaran
Copy link
Contributor

Thanks @naresh-bachwani for pointing this out! I tested this out using the new parameter and I can now see a 3d plot.

from yellowbrick.datasets import load_credit
from yellowbrick.features import PCADecomposition

X, y = load_credit()

visualizer = PCADecomposition(scale=True, projection=3)
visualizer.fit_transform(X, y)
visualizer.show()

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants