Skip to content

Commit

Permalink
Be slightly more strict on data type, see #41
Browse files Browse the repository at this point in the history
  • Loading branch information
davidavdav committed Mar 1, 2020
1 parent 77b72b5 commit 4c93c34
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/train.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ GMM(x::Vector{T}) where T <: AbstractFloat = GMM(reshape(x, length(x), 1)) # st

## constructors based on data or matrix
function GMM(n::Int, x::DataOrMatrix{T}; method::Symbol=:kmeans, kind=:diag,
nInit::Int=50, nIter::Int=10, nFinal::Int=nIter, sparse=0) where T
nInit::Int=50, nIter::Int=10, nFinal::Int=nIter, sparse=0) where T <: AbstractFloat
if n < 2
GMM(x, kind=kind)
elseif method==:split
Expand All @@ -40,7 +40,7 @@ function GMM(n::Int, x::DataOrMatrix{T}; method::Symbol=:kmeans, kind=:diag,
end
end
## a 1-dimensional Gaussian can be initialized with a vector, skip kind=
GMM(n::Int, x::Vector{T}; method::Symbol=:kmeans, nInit::Int=50, nIter::Int=10, nFinal::Int=nIter, sparse=0) where T = GMM(n, reshape(x, length(x), 1); method=method, kind=:diag, nInit=nInit, nIter=nIter, nFinal=nFinal, sparse=sparse)
GMM(n::Int, x::Vector{T}; method::Symbol=:kmeans, nInit::Int=50, nIter::Int=10, nFinal::Int=nIter, sparse=0) where T <: AbstractFloat = GMM(n, reshape(x, length(x), 1); method=method, kind=:diag, nInit=nInit, nIter=nIter, nFinal=nFinal, sparse=sparse)

## we sometimes end up with pathological gmms
function sanitycheck!(gmm::GMM)
Expand Down Expand Up @@ -72,7 +72,7 @@ end


## initialize GMM using Clustering.kmeans (which uses a method similar to kmeans++)
function GMMk(n::Int, x::DataOrMatrix{T}; kind=:diag, nInit::Int=50, nIter::Int=10, sparse=0) where T
function GMMk(n::Int, x::DataOrMatrix{T}; kind=:diag, nInit::Int=50, nIter::Int=10, sparse=0) where T <: AbstractFloat
nₓ, d = size(x)
hist = [History(@sprintf("Initializing GMM, %d Gaussians %s covariance %d dimensions using %d data points", n, diag, d, nₓ))]
@info(last(hist).s)
Expand Down

2 comments on commit 4c93c34

@davidavdav
Copy link
Owner Author

Choose a reason for hiding this comment

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

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/10354

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.2 -m "<description of version>" 4c93c34d8b0627b3d8a3088f35a676aa1b356789
git push origin v0.3.2

Please sign in to comment.