-
Notifications
You must be signed in to change notification settings - Fork 120
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
Issue #64: added n_init to kmeans #77
Conversation
@@ -43,18 +45,37 @@ function kmeans(X::Matrix, k::Int; | |||
weights=nothing, | |||
init=_kmeans_default_init, | |||
maxiter::Integer=_kmeans_default_maxiter, | |||
n_init::Integer=_kmeans_default_n_init, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use 4 space indents rather than tabs
|
||
function kmeans!{T<:AbstractFloat}(X::Matrix{T}, centers::Matrix{T}; | ||
weights=nothing, | ||
maxiter::Integer=_kmeans_default_maxiter, | ||
tol::Real=_kmeans_default_tol, | ||
display::Symbol=_kmeans_default_display) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated (and unnecessary) change--best to keep PRs focused on the task at hand
@@ -17,12 +17,14 @@ const _kmeans_default_init = :kmpp | |||
const _kmeans_default_maxiter = 100 | |||
const _kmeans_default_tol = 1.0e-6 | |||
const _kmeans_default_display = :none | |||
const _kmeans_default_n_init = 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, what's the motivation for a default of 10?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10 was chosen as this is the default for sklearn n_init param, and since we are duplicating this functionality, I just took this value.
maxiter=maxiter, | ||
tol=tol, | ||
display=display) | ||
n_init > 0 || error("n_init must be greater than 0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since n_init
is a function argument, the error should be an ArgumentError
. You can change this to
n_init > 0 || throw(ArgumentError("n_init must be greater than 0"))
775eefc
to
ea03689
Compare
Implementing n_init feature from sklearn mentioned in Issue 64.
First ever Julia or package commit, please let me know errors or what needs to be cleaned up.