Skip to content

Commit

Permalink
doc svm and nnmf
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffroyleconte authored and dpo committed Feb 20, 2024
1 parent b36e06a commit 0ab0453
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
3 changes: 1 addition & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ Requires = "ae029012-a4dd-5104-9daa-d747884805df"
[compat]
ADNLPModels = "^0.3, 0.4, 0.7"
Distributions = "0.25"
MLDatasets = "^0.7.4"
NLPModels = "0.16, 0.17, 0.18, 0.19, 0.20"
Noise = "0.2"
Requires = "1"
julia = "^1.3.0"
MLDatasets = "^0.7.4"

[extras]
ADNLPModels = "54578032-b7ea-4c30-94aa-7cbd1cce6c9a"
Expand All @@ -28,4 +28,3 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["ADNLPModels", "DifferentialEquations", "MLDatasets", "Test"]

1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ADNLPModels = "54578032-b7ea-4c30-94aa-7cbd1cce6c9a"
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
MLDatasets = "eb30cadb-4394-5ae3-aed4-317e484a6458"
RegularizedProblems = "ea076b23-609f-44d2-bb12-a4ae45328278"

[compat]
Expand Down
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Documenter
using ADNLPModels, DifferentialEquations
using ADNLPModels, DifferentialEquations, MLDatasets
using RegularizedProblems

makedocs(
Expand Down
21 changes: 19 additions & 2 deletions src/nnmf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,31 @@ function nnmf_data(m::Int, n::Int, k::Int, T::DataType = Float64)
parameters[i][2][j, j] = parameters[i][1][j] > 0.0 ? 0.3 : ϵ # to avoid problems in Cholesky factorization when calling MixtureModel
end
end
# generate a mixture of gaussians
# generate a mixture of gaussians
dist = MixtureModel(MvNormal, parameters)
# sample data
# sample data
A = rand(dist, m)'
A[A .< 0] .= 0
return A
end


"""
model, Av, selected = nnmf_model(m = 100, n = 50, k = 10, T = Float64)
Return an instance of an `NLPModel` representing the non-negative matrix factorization
objective
f(W, H) = ½ ‖A - WH‖₂²,
where A ∈ Rᵐˣⁿ has non-negative entries and can be separeted into k clusters, `Av = A[:]`.
The vector of indices `selected = k*m+1: k*(m+n)` is used to indicate the components of W ∈ Rᵐˣᵏ and H ∈ Rᵏˣⁿ to apply the regularizer to (so that the regularizer only applies to entries of H).
## Arguments
* `m :: Int`: the number of rows of A
* `n :: Int`: the number of columns of A (with `n` ≥ `m`)
* `k :: Int`: the number of clusters
"""
function nnmf_model(m::Int = 100, n::Int = 50, k::Int = 10, T::DataType = Float64)
A = nnmf_data(m, n, k, T)
r = similar(A, m * n)
Expand Down

0 comments on commit 0ab0453

Please sign in to comment.