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

Add class check when setting n_init inside K-modes constructor #194

Merged
merged 1 commit into from Apr 20, 2023

Conversation

DTchebotarev
Copy link
Contributor

Currently, when creating a KPrototypes instance, there's a misleading message, which says that n_init is 1, when it's actually not:

image

This occurs because n_init is actually being set twice: once within KPrototypes.__init__() and once again within KModes.__init__() as a result of the super(KPrototypes, self).__init__(...) call.

I'm adding a check within the KModes.__init__() method that actually checks that it's being called from KModes, and only do the n_init logic in that case. Now, the "Initialization method and algorithm are deterministic. Setting n_init to 1." is only printed when initializing K-modes with the Cao init, but suppressed when initializing K-prototypes.

image

@coveralls
Copy link

Coverage Status

Coverage: 97.942% (+0.009%) from 97.934% when pulling 41253f6 on DTchebotarev:master into 2d06e3c on nicodv:master.

Copy link
Owner

@nicodv nicodv left a comment

Choose a reason for hiding this comment

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

LGTM

@nicodv nicodv merged commit 82b813a into nicodv:master Apr 20, 2023
5 checks passed
@nicodv
Copy link
Owner

nicodv commented Apr 20, 2023

Thanks for the contribution, @DTchebotarev !

Coming back to this code some time after I wrote it, I think an even better solution is to not make KPrototypes inherit from KModes. But that's a fix for another day.

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