Skip to content

Commit

Permalink
Merge pull request #169 from lanl/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
MaksimEkin authored May 4, 2024
2 parents a0b2be7 + e8d26e4 commit 309eb02
Show file tree
Hide file tree
Showing 82 changed files with 352 additions and 277 deletions.
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ authors:
- family-names: Alexandrov
given-names: Boian
title: "Tensor Extraction of Latent Features (T-ELF)"
version: 0.0.18
version: 0.0.19
url: https://github.com/lanl/T-ELF
doi: 10.5281/zenodo.10257897
date-released: 2023-12-04
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ If you use T-ELF please cite.

**APA:**
```latex
Eren, M., Solovyev, N., Barron, R., Bhattarai, M., Truong, D., Boureima, I., Skau, E., Rasmussen, K., & Alexandrov, B. (2023). Tensor Extraction of Latent Features (T-ELF) (Version 0.0.18) [Computer software]. https://doi.org/10.5281/zenodo.10257897
Eren, M., Solovyev, N., Barron, R., Bhattarai, M., Truong, D., Boureima, I., Skau, E., Rasmussen, K., & Alexandrov, B. (2023). Tensor Extraction of Latent Features (T-ELF) (Version 0.0.19) [Computer software]. https://doi.org/10.5281/zenodo.10257897
```

**BibTeX:**
Expand Down
18 changes: 13 additions & 5 deletions TELF/factorization/HNMFk.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,11 @@ def fit(self, X, Ks, from_checkpoint=False, save_checkpoint=False):
if self.n_nodes > 1:
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
self.node_status = {}
for ii in range(1, self.n_nodes, 1):
self.node_status[ii] = {"free":True, "job":None}

# single node processing
else:
comm = None
rank = 0
self.node_status[0] = {"free": True, "job":None}


#
# Checkpointing and job setup
Expand Down Expand Up @@ -256,6 +251,16 @@ def fit(self, X, Ks, from_checkpoint=False, save_checkpoint=False):
"depth":0,
"parent_topic":None
}

# organize node status
if self.n_nodes > 1:
self.node_status = {}
for ii in range(1, self.n_nodes, 1):
self.node_status[ii] = {"free":True, "job":None}

else:
self.node_status = {}
self.node_status[0] = {"free": True, "job":None}

# save data matrix
self.X = X
Expand Down Expand Up @@ -355,6 +360,9 @@ def fit(self, X, Ks, from_checkpoint=False, save_checkpoint=False):
self.iterator = self.root
self._prepare_iterator(self.root)

if self.verbose:
print("Done")

return {"time":total_exec_seconds}


Expand Down
15 changes: 11 additions & 4 deletions TELF/factorization/NMFk.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,9 @@ def __init__(
k_search_method : str, optional
Which approach to use when searching for the rank or k. The default is "linear".\n
* ``k_search_method='linear'`` will linearly visit each K given in ``Ks`` hyper-parameter of the ``fit()`` function.\n
* ``k_search_method='bst_post'`` will perform post-order binary search. When an ideal rank is found, determined by the selected ``predict_k_method``, all lower ranks are pruned from the search space.
* ``k_search_method='bst_pre'`` will perform pre-order binary search. When an ideal rank is found, determined by the selected ``predict_k_method``, all lower ranks are pruned from the search space.
* ``k_search_method='bst_post'`` will perform post-order binary search. When an ideal rank is found, determined by the selected ``predict_k_method``, all lower ranks are pruned from the search space.\n
* ``k_search_method='bst_pre'`` will perform pre-order binary search. When an ideal rank is found, determined by the selected ``predict_k_method``, all lower ranks are pruned from the search space.\n
* ``k_search_method='bst_in'`` will perform in-order binary search. When an ideal rank is found, determined by the selected ``predict_k_method``, all lower ranks are pruned from the search space.
H_sill_thresh : float, optional
Setting for removing higher ranks from the search space.\n
When searching for the optimal rank with binary search using ``k_search='bst_post'`` or ``k_search='bst_pre'``, this hyper-parameter can be used to cut off higher ranks from search space.\n
Expand Down Expand Up @@ -694,7 +695,7 @@ def __init__(
self.H_sill_thresh = H_sill_thresh

# warnings
assert self.k_search_method in ["linear", "bst_pre", "bst_post"], "Invalid k_search_method method. Choose from linear, bst_pre, or bst_post."
assert self.k_search_method in ["linear", "bst_pre", "bst_post", "bst_in"], "Invalid k_search_method method. Choose from linear, bst_pre, bst_in, or bst_post."
assert self.predict_k_method in ["pvalue", "WH_sill", "W_sill", "H_sill", "sill"], "Invalid predict_k_method method. Choose from pvalue, WH_sill, W_sill, H_sill, or sill. sill defaults to WH_sill."

if self.predict_k_method == "sill":
Expand Down Expand Up @@ -863,11 +864,17 @@ def fit(self, X, Ks, name="NMFk", note=""):
node = BST.sorted_array_to_bst(Ks)
if self.K_search_settings["k_search_method"] == "bst_pre":
Ks = list(node.preorder())
if self.K_search_settings["k_search_method"] == "bst_post":
elif self.K_search_settings["k_search_method"] == "bst_post":
Ks = list(node.postorder())
elif self.K_search_settings["k_search_method"] == "bst_in":
Ks = list(node.inorder())
else:
raise Exception("Unknown k_search_method!")

if self.verbose:
print(f'Performing K search with {self.K_search_settings["k_search_method"]}. Ks={Ks}')


#
# check X format
#
Expand Down
16 changes: 12 additions & 4 deletions TELF/factorization/utilities/bst_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,19 @@ def preorder(self):
yield from self.left.preorder()
if self.right:
yield from self.right.preorder()

def postorder(self):
yield self.value
if self.left:
yield from self.left.postorder()
if self.right:
yield from self.right.preorder()
yield from self.right.postorder()
yield self.value

def inorder(self):
if self.left:
yield from self.left.preorder()
yield from self.left.postorder()
yield self.value
if self.right:
yield from self.right.postorder()


2 changes: 1 addition & 1 deletion TELF/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.0.18'
__version__ = '0.0.19'
6 changes: 3 additions & 3 deletions docs/Beaver.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

<title>TELF.pre_processing.Beaver: Fast matrix and tensor building tool &#8212; TELF 0.0.18 documentation</title>
<title>TELF.pre_processing.Beaver: Fast matrix and tensor building tool &#8212; TELF 0.0.19 documentation</title>



Expand Down Expand Up @@ -37,7 +37,7 @@
<link rel="preload" as="script" href="_static/scripts/pydata-sphinx-theme.js?digest=365ca57ee442770a23c6" />
<script src="_static/vendor/fontawesome/6.1.2/js/all.min.js?digest=365ca57ee442770a23c6"></script>

<script src="_static/documentation_options.js?v=4bf62f09"></script>
<script src="_static/documentation_options.js?v=f00aad14"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/scripts/sphinx-book-theme.js?digest=5a5c038af52cf7bc1a1ec88eea08e6366ee68824"></script>
Expand Down Expand Up @@ -127,7 +127,7 @@



<p class="title logo__title">TELF 0.0.18 documentation</p>
<p class="title logo__title">TELF 0.0.19 documentation</p>

</a></div>
<div class="sidebar-primary-item"><nav class="bd-links" id="bd-docs-nav" aria-label="Main">
Expand Down
6 changes: 3 additions & 3 deletions docs/Cheetah.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

<title>TELF.applications.Cheetah: Advanced search by keywords and phrases &#8212; TELF 0.0.18 documentation</title>
<title>TELF.applications.Cheetah: Advanced search by keywords and phrases &#8212; TELF 0.0.19 documentation</title>



Expand Down Expand Up @@ -37,7 +37,7 @@
<link rel="preload" as="script" href="_static/scripts/pydata-sphinx-theme.js?digest=365ca57ee442770a23c6" />
<script src="_static/vendor/fontawesome/6.1.2/js/all.min.js?digest=365ca57ee442770a23c6"></script>

<script src="_static/documentation_options.js?v=4bf62f09"></script>
<script src="_static/documentation_options.js?v=f00aad14"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/scripts/sphinx-book-theme.js?digest=5a5c038af52cf7bc1a1ec88eea08e6366ee68824"></script>
Expand Down Expand Up @@ -127,7 +127,7 @@



<p class="title logo__title">TELF 0.0.18 documentation</p>
<p class="title logo__title">TELF 0.0.19 documentation</p>

</a></div>
<div class="sidebar-primary-item"><nav class="bd-links" id="bd-docs-nav" aria-label="Main">
Expand Down
6 changes: 3 additions & 3 deletions docs/HNMFk.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

<title>TELF.factorization.HNMFk: Hierarchical Non-negative Matrix Factorization with Automatic Model Determination &#8212; TELF 0.0.18 documentation</title>
<title>TELF.factorization.HNMFk: Hierarchical Non-negative Matrix Factorization with Automatic Model Determination &#8212; TELF 0.0.19 documentation</title>



Expand Down Expand Up @@ -37,7 +37,7 @@
<link rel="preload" as="script" href="_static/scripts/pydata-sphinx-theme.js?digest=365ca57ee442770a23c6" />
<script src="_static/vendor/fontawesome/6.1.2/js/all.min.js?digest=365ca57ee442770a23c6"></script>

<script src="_static/documentation_options.js?v=4bf62f09"></script>
<script src="_static/documentation_options.js?v=f00aad14"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/scripts/sphinx-book-theme.js?digest=5a5c038af52cf7bc1a1ec88eea08e6366ee68824"></script>
Expand Down Expand Up @@ -127,7 +127,7 @@



<p class="title logo__title">TELF 0.0.18 documentation</p>
<p class="title logo__title">TELF 0.0.19 documentation</p>

</a></div>
<div class="sidebar-primary-item"><nav class="bd-links" id="bd-docs-nav" aria-label="Main">
Expand Down
7 changes: 4 additions & 3 deletions docs/NMFk.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

<title>TELF.factorization.NMFk: Non-negative Matrix Factorization with Automatic Model Determination &#8212; TELF 0.0.18 documentation</title>
<title>TELF.factorization.NMFk: Non-negative Matrix Factorization with Automatic Model Determination &#8212; TELF 0.0.19 documentation</title>



Expand Down Expand Up @@ -37,7 +37,7 @@
<link rel="preload" as="script" href="_static/scripts/pydata-sphinx-theme.js?digest=365ca57ee442770a23c6" />
<script src="_static/vendor/fontawesome/6.1.2/js/all.min.js?digest=365ca57ee442770a23c6"></script>

<script src="_static/documentation_options.js?v=4bf62f09"></script>
<script src="_static/documentation_options.js?v=f00aad14"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/scripts/sphinx-book-theme.js?digest=5a5c038af52cf7bc1a1ec88eea08e6366ee68824"></script>
Expand Down Expand Up @@ -127,7 +127,7 @@



<p class="title logo__title">TELF 0.0.18 documentation</p>
<p class="title logo__title">TELF 0.0.19 documentation</p>

</a></div>
<div class="sidebar-primary-item"><nav class="bd-links" id="bd-docs-nav" aria-label="Main">
Expand Down Expand Up @@ -528,6 +528,7 @@ <h1>Available Functions<a class="headerlink" href="#available-functions" title="
<li><p><code class="docutils literal notranslate"><span class="pre">k_search_method='linear'</span></code> will linearly visit each K given in <code class="docutils literal notranslate"><span class="pre">Ks</span></code> hyper-parameter of the <code class="docutils literal notranslate"><span class="pre">fit()</span></code> function.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">k_search_method='bst_post'</span></code> will perform post-order binary search. When an ideal rank is found, determined by the selected <code class="docutils literal notranslate"><span class="pre">predict_k_method</span></code>, all lower ranks are pruned from the search space.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">k_search_method='bst_pre'</span></code> will perform pre-order binary search. When an ideal rank is found, determined by the selected <code class="docutils literal notranslate"><span class="pre">predict_k_method</span></code>, all lower ranks are pruned from the search space.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">k_search_method='bst_in'</span></code> will perform in-order binary search. When an ideal rank is found, determined by the selected <code class="docutils literal notranslate"><span class="pre">predict_k_method</span></code>, all lower ranks are pruned from the search space.</p></li>
</ul>
</dd>
<dt>H_sill_thresh<span class="classifier">float, optional</span></dt><dd><p>Setting for removing higher ranks from the search space.</p>
Expand Down
6 changes: 3 additions & 3 deletions docs/RESCALk.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

<title>TELF.factorization.RESCALk: RESCAL with Automatic Model Determination &#8212; TELF 0.0.18 documentation</title>
<title>TELF.factorization.RESCALk: RESCAL with Automatic Model Determination &#8212; TELF 0.0.19 documentation</title>



Expand Down Expand Up @@ -37,7 +37,7 @@
<link rel="preload" as="script" href="_static/scripts/pydata-sphinx-theme.js?digest=365ca57ee442770a23c6" />
<script src="_static/vendor/fontawesome/6.1.2/js/all.min.js?digest=365ca57ee442770a23c6"></script>

<script src="_static/documentation_options.js?v=4bf62f09"></script>
<script src="_static/documentation_options.js?v=f00aad14"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/scripts/sphinx-book-theme.js?digest=5a5c038af52cf7bc1a1ec88eea08e6366ee68824"></script>
Expand Down Expand Up @@ -127,7 +127,7 @@



<p class="title logo__title">TELF 0.0.18 documentation</p>
<p class="title logo__title">TELF 0.0.19 documentation</p>

</a></div>
<div class="sidebar-primary-item"><nav class="bd-links" id="bd-docs-nav" aria-label="Main">
Expand Down
6 changes: 3 additions & 3 deletions docs/SymNMFk.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

<title>TELF.factorization.SymNMFk: Symmetric Non-negative Matrix Factorization with Automatic Model Determination &#8212; TELF 0.0.18 documentation</title>
<title>TELF.factorization.SymNMFk: Symmetric Non-negative Matrix Factorization with Automatic Model Determination &#8212; TELF 0.0.19 documentation</title>



Expand Down Expand Up @@ -37,7 +37,7 @@
<link rel="preload" as="script" href="_static/scripts/pydata-sphinx-theme.js?digest=365ca57ee442770a23c6" />
<script src="_static/vendor/fontawesome/6.1.2/js/all.min.js?digest=365ca57ee442770a23c6"></script>

<script src="_static/documentation_options.js?v=4bf62f09"></script>
<script src="_static/documentation_options.js?v=f00aad14"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/scripts/sphinx-book-theme.js?digest=5a5c038af52cf7bc1a1ec88eea08e6366ee68824"></script>
Expand Down Expand Up @@ -127,7 +127,7 @@



<p class="title logo__title">TELF 0.0.18 documentation</p>
<p class="title logo__title">TELF 0.0.19 documentation</p>

</a></div>
<div class="sidebar-primary-item"><nav class="bd-links" id="bd-docs-nav" aria-label="Main">
Expand Down
6 changes: 3 additions & 3 deletions docs/TELF.factorization.decompositions.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

<title>TELF.factorization.decompositions package &#8212; TELF 0.0.18 documentation</title>
<title>TELF.factorization.decompositions package &#8212; TELF 0.0.19 documentation</title>



Expand Down Expand Up @@ -37,7 +37,7 @@
<link rel="preload" as="script" href="_static/scripts/pydata-sphinx-theme.js?digest=365ca57ee442770a23c6" />
<script src="_static/vendor/fontawesome/6.1.2/js/all.min.js?digest=365ca57ee442770a23c6"></script>

<script src="_static/documentation_options.js?v=4bf62f09"></script>
<script src="_static/documentation_options.js?v=f00aad14"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/scripts/sphinx-book-theme.js?digest=5a5c038af52cf7bc1a1ec88eea08e6366ee68824"></script>
Expand Down Expand Up @@ -128,7 +128,7 @@



<p class="title logo__title">TELF 0.0.18 documentation</p>
<p class="title logo__title">TELF 0.0.19 documentation</p>

</a></div>
<div class="sidebar-primary-item"><nav class="bd-links" id="bd-docs-nav" aria-label="Main">
Expand Down
6 changes: 3 additions & 3 deletions docs/TELF.factorization.decompositions.utilities.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

<title>TELF.factorization.decompositions.utilities package &#8212; TELF 0.0.18 documentation</title>
<title>TELF.factorization.decompositions.utilities package &#8212; TELF 0.0.19 documentation</title>



Expand Down Expand Up @@ -37,7 +37,7 @@
<link rel="preload" as="script" href="_static/scripts/pydata-sphinx-theme.js?digest=365ca57ee442770a23c6" />
<script src="_static/vendor/fontawesome/6.1.2/js/all.min.js?digest=365ca57ee442770a23c6"></script>

<script src="_static/documentation_options.js?v=4bf62f09"></script>
<script src="_static/documentation_options.js?v=f00aad14"></script>
<script src="_static/doctools.js?v=888ff710"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/scripts/sphinx-book-theme.js?digest=5a5c038af52cf7bc1a1ec88eea08e6366ee68824"></script>
Expand Down Expand Up @@ -127,7 +127,7 @@



<p class="title logo__title">TELF 0.0.18 documentation</p>
<p class="title logo__title">TELF 0.0.19 documentation</p>

</a></div>
<div class="sidebar-primary-item"><nav class="bd-links" id="bd-docs-nav" aria-label="Main">
Expand Down
Loading

0 comments on commit 309eb02

Please sign in to comment.