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

API: follow sklearn api conventions #59

Merged
merged 5 commits into from
Jul 18, 2023
Merged

API: follow sklearn api conventions #59

merged 5 commits into from
Jul 18, 2023

Conversation

martinfleis
Copy link
Owner

@martinfleis martinfleis commented Jul 18, 2023

Closes #55

  • avoid modification of parameters
  • move checks to fit()
  • store fitted parameters with an underscore
  • ensure fit() has a sklearn-compatible signature
  • return self in fit()
  • ensure new call to fit() clears the data

Generally following https://scikit-learn.org/stable/developers/develop.html when it makes sense to follow it.

Other plotting-classes within the scikit-learn package typically implement “from_estimator” and “from_predictions” class methods (e.g. ConfusionMatrixDisplay, PredictionErrorDisplay, etc.). In this way it is easy to use the class with any class that would provide clustering data. The current implementation of the class provides from_data() and from_centers() methods, which achieve similar, but not directly compatible behavior.

Given the nature of Clustergram being typically composed of a series of estimators differing in a number of clusters, it is not possible to create an API like this that is compatible with existing sklearn plotting classes. I suppose that our existing alternative constructors are sufficient in this case.

@codecov-commenter
Copy link

codecov-commenter commented Jul 18, 2023

Codecov Report

Patch coverage: 96.10% and project coverage change: +1.62 🎉

Comparison is base (b64916c) 80.86% compared to head (8b4d44c) 82.49%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #59      +/-   ##
==========================================
+ Coverage   80.86%   82.49%   +1.62%     
==========================================
  Files           2        2              
  Lines         345      377      +32     
==========================================
+ Hits          279      311      +32     
  Misses         66       66              
Impacted Files Coverage Δ
clustergram/clustergram.py 82.16% <96.10%> (+1.68%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@martinfleis martinfleis marked this pull request as ready for review July 18, 2023 20:45
@martinfleis martinfleis merged commit 1475a8a into main Jul 18, 2023
8 checks passed
@martinfleis martinfleis deleted the sklearn_api branch July 18, 2023 20:50
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.

Follow the sklearn API guide
2 participants