Skip to content

Commit

Permalink
add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
youdongguo committed May 28, 2024
1 parent e035354 commit ca636b5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,15 @@
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://HolyLab.github.io/NMFMerge.jl/dev/)
[![Build Status](https://github.com/HolyLab/NMFMerge.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/HolyLab/NMFMerge.jl/actions/workflows/CI.yml?query=branch%3Amain)
[![Coverage](https://codecov.io/gh/HolyLab/NMFMerge.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/HolyLab/NMFMerge.jl)

This package includes the code the paper ``
It is used for merging components in non-negative matrix factorization.
All of the examples below assume you've loaded the package with `using FlyThroughPaths`.


## Functions

**colmerge2to1pq**colmerge2to1pq(W, H, n)

This function merges components in ``W`` and ``H`` (columns in ``W`` and rows in ``H``) from original number of components to ``n`` components (``n``columns and rows left in ``W`` and ``H`` respectively)

1 change: 0 additions & 1 deletion src/NMF_Merge.jl → src/NMFMerge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ using LinearAlgebra, DataStructures

export colnormalize,
colmerge2to1pq,
mergecol2to1!,
mergecolumns

function colnormalize(W, H, p::Int=2)
Expand Down
8 changes: 7 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ end

W2 = [W1n[:, j] for j in axes(W1n, 2)];
H2 = [H1n[i, :] for i in axes(H1n, 1)];

Q1, Q2, _, _, _, _ =build_Qs(W2, H2, 1, 2)
@test Q1 == Q1'
@test Q2 == Q2
Expand All @@ -51,8 +52,13 @@ end
@test abs(λ_min - minimum(F.values))<=1e-12

@test abs(u[1]/u[2] - w[1]/w[2])<1e-3*(u[1]/u[2] + w[1]/w[2])/2

# @show u
# @show w
# @show u[1]/u[2]
# @show w[1]/w[2]

w = [u[1], u[2]]
@test norm(w) 1
@test norm(Q1*w - maximum(F.values)*Q2*w) < 1e-12

W12, H12, loss = NMFMerge.mergepair(W2, H2, 1, 2)
Expand Down

0 comments on commit ca636b5

Please sign in to comment.