{"id":22668528,"url":"https://github.com/lanl/pydrescalk","last_synced_at":"2025-04-12T11:05:54.509Z","repository":{"id":141730868,"uuid":"434806925","full_name":"lanl/pyDRESCALk","owner":"lanl","description":"Distributed Non Negative RESCAL decomposition with estimation of latent features ","archived":false,"fork":false,"pushed_at":"2023-08-30T17:02:24.000Z","size":6830,"stargazers_count":2,"open_issues_count":0,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-06-27T00:19:27.169Z","etag":null,"topics":["artificial-intelligence","clustering-algorithm","distributed-cpu","distributed-gpu","dynamic-networks","latent-variables","nonnegative-tensor-decomposition","parallel-programming","relational-data","relational-learning","relational-model","unsupervised-learning"],"latest_commit_sha":null,"homepage":"https://lanl.github.io/pyDRESCALk/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lanl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-12-04T04:34:12.000Z","updated_at":"2021-12-06T18:15:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"655fccf2-41fb-4bff-9597-63b77ed420e2","html_url":"https://github.com/lanl/pyDRESCALk","commit_stats":{"total_commits":14,"total_committers":2,"mean_commits":7.0,"dds":0.3571428571428571,"last_synced_commit":"adc433add5543a6552226b36d2ffde293dce4171"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lanl%2FpyDRESCALk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lanl%2FpyDRESCALk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lanl%2FpyDRESCALk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lanl%2FpyDRESCALk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lanl","download_url":"https://codeload.github.com/lanl/pyDRESCALk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228911888,"owners_count":17990774,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["artificial-intelligence","clustering-algorithm","distributed-cpu","distributed-gpu","dynamic-networks","latent-variables","nonnegative-tensor-decomposition","parallel-programming","relational-data","relational-learning","relational-model","unsupervised-learning"],"created_at":"2024-12-09T15:15:38.152Z","updated_at":"2024-12-09T15:15:38.985Z","avatar_url":"https://github.com/lanl.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [pyDRESCALk: Python Distributed Non Negative RESCAL with determination of hidden features](https://github.com/lanl/pyDRESCALk)\n\n\n\u003cdiv align=\"center\", style=\"font-size: 50px\"\u003e\n\n[![Build Status](https://github.com/lanl/pyDRESCALk/actions/workflows/ci_test.yml/badge.svg?branch=main)](https://github.com/lanl/pyDRESCALk/actions/workflows/ci_test.yml/badge.svg?branch=main) [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg) [![Python Version](https://img.shields.io/badge/python-v3.7.1-blue)](https://img.shields.io/badge/python-v3.7.1-blue) [![DOI](https://zenodo.org/badge/434806925.svg)](https://zenodo.org/badge/latestdoi/434806925)\n\n\u003c/div\u003e\n\n\n\u003cbr\u003e\n\n[pyDRESCALk](https://github.com/lanl/pyDRESCALk) is a software package for applying non-negative RESCAL decomposition in a distributed fashion to large datasets. It can be utilized for decomposing relational datasets. It can minimize the difference between reconstructed data and the original data through Frobenius norm.  Additionally, the Custom Clustering algorithm allows for automated determination for the number of Latent features.\n\n\u003cdiv align=\"center\", style=\"font-size: 50px\"\u003e\n\n### [:information_source: Documentation](https://lanl.github.io/pyDRESCALk/) \u0026emsp; [:orange_book: Examples](examples/) \u0026emsp; [:bar_chart: Datasets](data/) \u0026emsp; [:page_facing_up: Paper](https://ieeexplore.ieee.org/abstract/document/9286234)\n\n\u003c/div\u003e\n\n\u003chr/\u003e\n\n\n![plot](./docs/pyDRESCALk.png)\n\n## Features:\n* Ability to decompose relational datasets.\n* Utilization of MPI4py for distributed operation.\n* Distributed random initializations.\n* Distributed Custom Clustering algorithm for estimating automated latent feature number (k) determination.\n* Objective of minimization of Frobenius norm. \n* Support for distributed CPUs/GPUs.\n* Support for Dense/Sparse data.\n* Demonstrated scaling performance upto 10TB of dense and 9Exabytes of Sparse data. \n\n![plot](./docs/overview.png)\n\nOverview of the pyDRESCALk workflow implementation.\n## Installation:\n\nOn a desktop machine:\n```\ngit clone https://github.com/lanl/pyDRESCALk.git\ncd pyDRESCALk\nconda create --name pyDRESCALk python=3.7.1 openmpi mpi4py\nsource activate pyDRESCALk\npython setup.py install\n```\n\n\u003chr/\u003e\n\nOn a HPC server:\n```\ngit clone https://github.com/lanl/pyDRESCALk.git\ncd pyDRESCALk\nconda create --name pyDRESCALk python=3.7.1 \nsource activate pyDRESCALk\nmodule load \u003copenmpi\u003e\npip install mpi4py\npython setup.py install\n```\n\n## Prerequisites\n* conda\n* numpy\u003e=1.2\n* matplotlib\n* MPI4py\n* scipy\n* h5py\n\n## Documentation\n\nYou can find the documentation [here](https://lanl.github.io/pyDRESCALk/). \n\n\n## Usage\n**[main.py](main.py) can be used to run the software on command line:**\n\n```bash\nmpirun -n \u003cprocs\u003e python main.py [-h] [--process PROCESS] --p_r P_R --p_c P_C [--k K]\n               [--fpath FPATH] [--ftype FTYPE] [--fname FNAME] [--init INIT]\n               [--itr ITR] [--norm NORM] [--method METHOD] [--verbose VERBOSE]\n               [--results_path RESULTS_PATH] \n               [--timing_stats TIMING_STATS] \n               [--precision PRECISION] [--perturbations PERTURBATIONS]\n               [--noise_var NOISE_VAR] [--start_k START_K] [--end_k END_K]\n               [--step_k STEP_K]  [--sampling SAMPLING] [--key KEY]\n\n\narguments:\n  -h, --help            show this help message and exit\n  --process PROCESS     pyDRESCAL/pyDRESCALk\n  --p_r P_R             Now of row processors\n  --p_c P_C             Now of column processors\n  --k K                 feature count\n  --fpath FPATH         data path to read(eg: tmp/)\n  --ftype FTYPE         data type : mat/folder/h5\n  --fname FNAME         File name\n  --init INIT           RESCAL initializations: rand/nnsvd\n  --itr ITR             RESCAL iterations, default:1000\n  --norm NORM           Reconstruction Norm for NMF to optimize:FRO\n  --method METHOD       RESCAL update method:MU/BCD/HALS\n  --verbose VERBOSE\n  --results_path RESULTS_PATH\n                        Path for saving results\n  --timing_stats TIMING_STATS\n                        Switch to turn on/off benchmarking.\n  --prune PRUNE         Prune zero row/column.\n  --precision PRECISION\n                        Precision of the data(float32/float64/float16).\n  --perturbations PERTURBATIONS\n                        perturbation for RESCALk\n  --noise_var NOISE_VAR\n                        Noise variance for RESCALk\n  --start_k START_K     Start index of K for RESCALk\n  --end_k END_K         End index of K for RESCALk\n  --step_k STEP_K       step for K search\n  --sampling SAMPLING   Sampling noise for NMFk i.e uniform/poisson\n  --key KEY             Key for data if strored in dictionary. \n```\n\n**Example on running  pyDRESALk using [main.py](main.py):**\n```bash\nmpirun -n 4 python main.py --p_r=2 --p_c=2 --process='pyDRESCALk'  --fpath='data/' --ftype='mat' --fname='dnations' --init='rand' --itr=5000 --norm='fro' --method='mu' --results_path='results/' --perturbation=20 --noise_var=0.015 --start_k=2 --end_k=5  --sampling='uniform' --data_key='R'\n```\n\n**Example estimation of k using the provided sample dataset:**\n```python\n'''Imports block'''\n\nimport sys\nimport pyDRESCALk.config as config\nconfig.init(0)\nfrom pyDRESCALk.pyDRESCALk import *\nfrom pyDRESCALk.data_io import *\nfrom pyDRESCALk.dist_comm import *\nfrom scipy.io import loadmat\nfrom mpi4py import MPI\ncomm = MPI.COMM_WORLD\nargs = parse()\ncomm = MPI.COMM_WORLD\np_r, p_c = 2, 2\ncomms = MPI_comm(comm, p_r, p_c)\ncomm1 = comms.comm\nrank = comm.rank\nsize = comm.size\nargs = parse()\nargs.size, args.rank, args.comm, args.p_r, args.p_c = size, rank, comms, p_r, p_c\nargs.row_comm, args.col_comm, args.comm1 = comms.cart_1d_row(), comms.cart_1d_column(), comm1\nrank = comms.rank\nargs.fpath = '../data/'\nargs.fname = 'dnations'\nargs.ftype = 'mat'\nargs.start_k = 2\nargs.end_k = 5\nargs.itr = 200\nargs.init = 'rand'\nargs.noise_var = 0.005\nargs.verbose = True\nargs.norm = 'fro'\nargs.method = 'mu'\nargs.np = np\nargs.precision = np.float32\nargs.key = 'R'\nA_ij = np.moveaxis(data_read(args).read().astype(args.precision),-1,0) #Always make data of dimension mxnxn.\nprint('Data dimension for rank=',rank,'=',A_ij.shape)\nargs.results_path = '../Results/'\npyDRESCALk(A_ij, factors=None, params=args).fit()\n\n```\n\n**See the [examples](examples/) or [tests](tests/) for more use cases.**\n\u003chr/\u003e\n\n## Benchmarking\n\n![plot](./docs/benchmark.png)\nFigure: Scaling benchmarks for 10 iterations for Frobenius norm based MU updates with MPI\noperations for i) strong and ii) weak scaling and  Communication vs computation \noperations for iii) strong and iv) weak scaling. \n\n## Scalability\n![plot](./docs/scalability.png)\n\n## Authors\n\n* [Manish Bhattarai](mailto:ceodspspectrum@lanl.gov) - Los Alamos National Laboratory\n* [Namita Kharat](mailto:namita@lanl.gov) - Los Alamos National Laboratory\n* [Erik Skau](mailto:ewskau@lanl.gov) - Los Alamos National Laboratory\n* [Duc Truong](mailto:dptruong@lanl.gov) - Los Alamos National Laboratory\n* [Maksim Eren](mailto:maksim@lanl.gov) - Los Alamos National Laboratory\n* [Sanjay Rajopadhye](mailto:Sanjay.Rajopadhye@ColoState.EDU) - Colorado State University\n* [Hristo Djidjev](mailto:djidjev@lanl.gov) - Los Alamos National Laboratory\n* [Boian Alexandrov](mailto:boian@lanl.gov) - Los Alamos National Laboratory\n\n## How to cite pyDRESCALk?\n\n```latex\n\n@software{pyDRESCALk,\n  author       = {Bhattarai, Manish and\n                  Kharat, Namita and\n                  Skau, Erik and\n                  Truong, Duc and\n                  Eren, Maksim and\n                  Rajopadhye, Sanjay and\n                  Djidjev, Hristo and\n                  Alexandrov, Boian},\n  title        = {pyDRESCALk: Python Distributed Non Negative RESCAL decomposition with determination of latent features},\n  month        = dec,\n  year         = 2021,\n  publisher    = {Zenodo},\n  version      = {v1.0.0},\n  doi          = {10.5281/zenodo.5758446},\n  url          = {https://doi.org/10.5281/zenodo.5758446}\n}\n\n\n@article{bhattarai2023distributed,\n  title={Distributed non-negative rescal with automatic model selection for exascale data},\n  author={Bhattarai, Manish and Boureima, Ismael and Skau, Erik and Nebgen, Benjamin and Djidjev, Hristo and Rajopadhye, Sanjay and Smith, James P and Alexandrov, Boian and others},\n  journal={Journal of Parallel and Distributed Computing},\n  volume={179},\n  pages={104709},\n  year={2023},\n  publisher={Elsevier}\n}\n\n\n\n```\n\n## Acknowledgments\nLos Alamos National Lab (LANL), T-1\n\n## Copyright Notice\n\u003e© (or copyright) 2020. Triad National Security, LLC. All rights reserved.\nThis program was produced under U.S. Government contract 89233218CNA000001 for Los Alamos\nNational Laboratory (LANL), which is operated by Triad National Security, LLC for the U.S.\nDepartment of Energy/National Nuclear Security Administration. All rights in the program are\nreserved by Triad National Security, LLC, and the U.S. Department of Energy/National Nuclear\nSecurity Administration. The Government is granted for itself and others acting on its behalf a\nnonexclusive, paid-up, irrevocable worldwide license in this material to reproduce, prepare\nderivative works, distribute copies to the public, perform publicly and display publicly, and to permit\nothers to do so.\n\n\n## License\n\nThis program is open source under the BSD-3 License.\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n\n3. Neither the name of the copyright holder nor the names of its\n   contributors may be used to endorse or promote products derived from\n   this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\nFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\nOR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flanl%2Fpydrescalk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flanl%2Fpydrescalk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flanl%2Fpydrescalk/lists"}