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

Allowing FPS to take numpy array of ints as initialize parameter #225

Merged
merged 14 commits into from
May 16, 2024

Conversation

cajchristian
Copy link
Contributor

@cajchristian cajchristian commented May 1, 2024

Hello!

This pull request is my attempt to address issue #145. With these changes, FPS should be able to accept a numpy array of ints as an input. I wrote a few tests as well to ensure the updated code is functioning properly. I'd love to hear any feedback you may have!

Contributor (creator of PR) checklist

  • Tests updated (for new features and bugfixes)?
  • Documentation updated (for new features)?
  • Issue referenced (for PRs that solve an issue)?

For Reviewer

  • CHANGELOG updated if important change?

📚 Documentation preview 📚: https://scikit-matter--225.org.readthedocs.build/en/225/

@cajchristian cajchristian marked this pull request as ready for review May 1, 2024 15:25
@rosecers rosecers self-requested a review May 2, 2024 18:07
@rosecers rosecers marked this pull request as draft May 2, 2024 18:07
@cajchristian cajchristian marked this pull request as ready for review May 2, 2024 20:20
self.selected_idx_[i] = val
self._update_post_selection(X, y, self.selected_idx_[i])
else:
raise ValueError("Initialize parameter must contain only int")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would you mind adding a test for this error raise?

You can take a look how to test that in the pytest docs or find another example in our test suite

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be fixed now. Added the unit tests I wrote in test_feature_simple_fps to test_sample_simple_fps. Let me know if this looks correct!

@@ -1038,7 +1038,14 @@ def _init_greedy_search(self, X, y, n_to_select):
self.hausdorff_ = np.full(X.shape[self._axis], np.inf)
self.hausdorff_at_select_ = np.full(X.shape[self._axis], np.inf)

if self.initialize == "random":
if isinstance(self.initialize, np.ndarray):
Copy link
Collaborator

@PicoCentauri PicoCentauri May 6, 2024

Choose a reason for hiding this comment

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

Shouldn't these operattions also be performed for a List and not only for a numpy array? Something like

if isinstance(self.initialize, np.ndarray) or isinstance(self.initialize, list):

Even though there is probably a shorter way to check of an instance belongs to either one of two classes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Let me know what you think about the new changes I made.

Copy link
Collaborator

@PicoCentauri PicoCentauri left a comment

Choose a reason for hiding this comment

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

Yes looks good. Can you add to the CHANGELOG?

@cajchristian
Copy link
Contributor Author

Updated the changelog!

Copy link
Collaborator

@PicoCentauri PicoCentauri left a comment

Choose a reason for hiding this comment

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

Very nice. Thanks for this addition! Let's wait until CI is finished.

@rosecers rosecers merged commit dd31493 into scikit-learn-contrib:main May 16, 2024
10 checks passed
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.

3 participants