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

Addressing issue #589: Adding alpha params to PCA #807

Closed
wants to merge 2 commits into from
Closed

Addressing issue #589: Adding alpha params to PCA #807

wants to merge 2 commits into from

Conversation

naresh-bachwani
Copy link
Contributor

@naresh-bachwani naresh-bachwani commented Apr 5, 2019

The following changes were made to PCA referenced #589 :

  1. Added new parameter alpha to pca.py to specify the opacity.
  2. Modified test_pca.py

The result is attached below:
Screenshot (144)

@lwgray
Copy link
Contributor

lwgray commented Apr 6, 2019

@naresh-bachwani This PR still has changes for residuals.

@lwgray
Copy link
Contributor

lwgray commented Apr 7, 2019

@naresh-bachwani you have changes for both residuals and PCA in this PR. This needs to be rectified before we move forward

@naresh-bachwani
Copy link
Contributor Author

Hello @lwgray,
Sorry for this error. I'm new to OpenSource, so please guide me towards what needs to be done in order to rectify this. I have made the changes related to residuals in develop branch and adding a new branch for PCA won't work! So should I close this PR until the previous one is merged, if not then please guide me towards what needs to be done!

@lwgray
Copy link
Contributor

lwgray commented Apr 7, 2019

@naresh-bachwani I am inclined to say to wait until merging #806. Then once your develop is up-to-date, you should create a feature-branch off of develop for the PCA alpha work.

@lwgray
Copy link
Contributor

lwgray commented Apr 7, 2019

If you like, I can still make comments here while we wait then you can apply them in the new PR

@naresh-bachwani
Copy link
Contributor Author

OK. That will be great

@@ -164,7 +164,7 @@ def test_biplot_3d(self):
pca_array = visualizer.transform(self.dataset.X)

# Image comparison tests
self.assert_images_similar(visualizer)
self.assert_images_similar(visualizer,tol=10)

# Assert PCA transformation occurred successfully
assert pca_array.shape == (self.dataset.X.shape[0], 3)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to add a test for alpha. It could be similar to the alpha test found in residuals.py

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I will construct a function for alpha test.

@@ -118,7 +119,7 @@ def __init__(self,
[('scale', StandardScaler(with_std=self.scale)),
('pca', PCA(self.proj_dim, random_state=random_state))]
)

self.alpha=alpha
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is exactly right. Additionally, We should include alpha parameter in the docstring above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

@@ -154,7 +155,7 @@ def transform(self, X, y=None, **kwargs):
def draw(self, **kwargs):
X = self.pca_features_
if self.proj_dim == 2:
self.ax.scatter(X[:, 0], X[:, 1], c=self.color, cmap=self.colormap)
self.ax.scatter(X[:, 0], X[:, 1], c=self.color, cmap=self.colormap,alpha=self.alpha)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

place a space after the comma right before alpha

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Will do so!

@@ -177,7 +178,7 @@ def draw(self, **kwargs):
self.fig = plt.figure()
self.ax = self.fig.add_subplot(111, projection='3d')
self.ax.scatter(X[:, 0], X[:, 1], X[:, 2],
c=self.color, cmap=self.colormap)
c=self.color, cmap=self.colormap,alpha=self.alpha)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

place a space after the comma right before alpha

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Will do so!

@@ -215,7 +216,7 @@ def finalize(self, **kwargs):

def pca_decomposition(X, y=None, ax=None, features=None, scale=True,
proj_dim=2, proj_features=False, color=None,
colormap=palettes.DEFAULT_SEQUENCE,
colormap=palettes.DEFAULT_SEQUENCE,alpha=1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

place a space after the comma right before alpha

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Will do so!

@lwgray
Copy link
Contributor

lwgray commented Apr 9, 2019

@naresh-bachwani #806 was merged so whenever you are ready to open a new PR for PCA alpha, go ahead. Just make sure you local develop branch is in sync with upstream yellowbrick develop branch prior to creating any new feature branches

@naresh-bachwani
Copy link
Contributor Author

@lwgray, I will make a new PR once I have my test for alpha ready!!

@naresh-bachwani
Copy link
Contributor Author

Hello, @lwgray @rebeccabilbro,
What should be the default value for alpha in this case? If default alpha=0.75, then we can either increase tolerance or we need to make changes to baseline images. What should I do in this case? Please guide!

@lwgray
Copy link
Contributor

lwgray commented Apr 10, 2019

@naresh-bachwani let’s move this discussion to the new PR even if not all the tests are passing.

@naresh-bachwani
Copy link
Contributor Author

Ok! I am closing this PR and opening a new one.

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

Successfully merging this pull request may close these issues.

None yet

3 participants