Repository navigation
[MNT] Restructure the distance based clusterers in get_clusterer_by_name - #552
Open
MatthewMiddlehurst wants to merge 8 commits into
Open
MatthewMiddlehurst wants to merge 8 commits into
MatthewMiddlehurst wants to merge 8 commits into
Conversation
Match names exactly like the other getters, instead of using substrings. The distance is taken from the name once, and kwargs are only passed on. The clusterers and parameters returned are unchanged. ElasticSOM now receives kwargs, which were ignored. The "No distance metric specified" print is removed.
One branch per name in distance_based_clusterers with its settings written
out, as in the other getters, instead of splitting the distance from the
name. Distances without default parameters now leave distance_params as None
rather than {}. Only the data dependent ERP g still uses a helper. Remove the
TimeSeriesKernelKMeans branch, which had no name in the list.
Uses the settings of the branch which could not be reached before.
Remove arguments equal to the aeon defaults, which are the same in aeon 1.0 to 1.6. The averaging distance is added by TimeSeriesKMeans, so average_params only holds the non-default distance settings. KShape keeps tol=1e-06, which only became its default in aeon 1.4.
aeon barycentre averaging does not support lcss, and erp support was removed in aeon 1.3.0, so kmeans-ba-lcss, kmeans-ba-erp and kmeans-ssg-ba-erp always raised in fit.
Pass n_jobs to TimeSeriesKMeans, KSpectralCentroid and KShape. The ERP g was found from the default train split. Resample the data when the experiment does, and include the test data when the train and test splits are combined, so g comes from the data the clusterer is fit on.
Contributor
Thank you for contributing to
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Reference Issues/PRs
Follows a review of the estimator getters. The classifier and regressor fixes were in #550.
What does this implement/fix? Explain your changes
Rewrites the distance based clusterers in
get_clusterer_by_namein the same format as the classifier and regressor getters.The old function picked the clusterer with substring tests (
"ba" in c,"pam" in c,"som" in c,"clara"after"clarans"), so the result depended on branch order. It parsed a distance from every name and looked up its parameters in_get_distance_default_params. It also readinit_algorithm,distance,distance_paramsandaverage_paramsfrom kwargs before passing kwargs on as well, so setting any of them raisedTypeError.kasba,kshape,kscand the class names printed "No distance metric specified, using default DTW".Now:
distance_based_clusterershas its own branch, and each branch imports its clusterer.TimeSeriesKMeansadds the averaging distance itself, soaverage_paramsonly holds the non-default distance settings.TypeErroron a conflicting keyword, as in the other getters.n_jobsis passed toTimeSeriesKMeans,KSpectralCentroidandKShape, which take it from aeon 1.3 and 1.4. Before, it was only used for the kernel k-means branch, which could not be reached.g, which can depend on the data, still uses a helper (_get_erp_g, the ERP part of_get_distance_default_params). It used to computegfrom the default train split loaded from disk, even when the experiment resampled the data or combined the train and test splits. It now resamples with the experiment's seed, andclustering_experiments.pyadds the combine flag as a fifth item ofdata_vars, sogcomes from the data the clusterer is fit on.timeserieskernelkmeansis added to the list, so its branch, which could not be reached before, now works. It needs tslearn. The test exclusion forTimeSeriesKernelKMeansis removed.kmeans-ba-lcss,kmeans-ba-erpandkmeans-ssg-ba-erpare removed because they always raised infit. aeon's barycentre averaging has never supported lcss in aeon 1.x, and erp support was removed in aeon 1.3.0.ValueError, and**kwargsis documented.Compared with
main, every remaining name builds the same clusterer type, and fits on MinimalChinatown give the same labels.