Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR add an implementation of the k-means algorithm written in JAX.
By replacing the current calls to the
sklearn
implementation with this new implementation, we can nowvmap
andjit
code which uses kmeans for initialization. We can also removescikit-learn
as a core dependency (it is still used in some demos).Details
The changes are currently structured into different commits as follows:
sklearn
kmeans implementation todynamax.utils.cluster
.sklearn
kmeans to use the new utility function.dynamax.utils.cluster
which is compatible with JAX transformations.Further Testing
It would be nice to be able to test if the new implementation does roughly as good a job as the sklearn implementation (it is considerably less complex). From playing about with it thus far once I added k-means++ initialisation it seemed to work pretty well.
I'm currently working on some test code where I patch in the new implementation and check that we can get about the same goodness of fit.
Final changes before merging
Before merging I will replace the current calls to
kmeans_sklearn
withkmeans_jax
(and perhaps rename it) and remove thekmeans_sklearn
function fromdynamax.utils.cluster
.Questions:
dynamax.utils
?Related issues:
Closes #315.