{"id":32174982,"url":"https://github.com/uriamorp/mprod_package","last_synced_at":"2025-10-21T19:19:47.093Z","repository":{"id":45240652,"uuid":"426668480","full_name":"UriaMorP/mprod_package","owner":"UriaMorP","description":"Software implementation for tensor-tensor m-product","archived":false,"fork":false,"pushed_at":"2023-12-14T10:21:02.000Z","size":1682,"stargazers_count":14,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-09-25T08:35:30.919Z","etag":null,"topics":["data-science","linear-algebra","multiway","numerical-analysis","pca","python","scientific-computing","spatio-temporal","tca","tcam","tensor","tensor-algebra","tensor-decomposition","tensor-factorization","tensor-product","time-series-analysis"],"latest_commit_sha":null,"homepage":"","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/UriaMorP.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,"roadmap":null,"authors":null}},"created_at":"2021-11-10T15:10:44.000Z","updated_at":"2025-05-03T23:37:22.000Z","dependencies_parsed_at":"2023-12-14T10:56:13.422Z","dependency_job_id":"34069d61-268f-48b0-92b7-3f8ab842ab45","html_url":"https://github.com/UriaMorP/mprod_package","commit_stats":{"total_commits":127,"total_committers":2,"mean_commits":63.5,"dds":"0.45669291338582674","last_synced_commit":"cbe5e82f4fc31bb076826f0ec642e9ea05f13bfa"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/UriaMorP/mprod_package","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UriaMorP%2Fmprod_package","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UriaMorP%2Fmprod_package/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UriaMorP%2Fmprod_package/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UriaMorP%2Fmprod_package/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UriaMorP","download_url":"https://codeload.github.com/UriaMorP/mprod_package/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UriaMorP%2Fmprod_package/sbom","scorecard":{"id":146348,"data":{"date":"2025-08-11","repo":{"name":"github.com/UriaMorP/mprod_package","commit":"cbe5e82f4fc31bb076826f0ec642e9ea05f13bfa"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/23 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/build.yaml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yaml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/UriaMorP/mprod_package/build.yaml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yaml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/UriaMorP/mprod_package/build.yaml/main?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/build.yaml:25","Warn: pipCommand not pinned by hash: .github/workflows/build.yaml:26","Warn: pipCommand not pinned by hash: .github/workflows/build.yaml:27","Warn: pipCommand not pinned by hash: .github/workflows/build.yaml:28","Warn: pipCommand not pinned by hash: .github/workflows/build.yaml:29","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   5 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: BSD 3-Clause \"New\" or \"Revised\" License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":4,"reason":"6 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-6p56-wp2h-9hxr","Warn: Project is vulnerable to: GHSA-fpfv-jqm9-f5jm","Warn: Project is vulnerable to: PYSEC-2024-110 / GHSA-jw8x-6495-233v","Warn: Project is vulnerable to: GHSA-jxfp-4rvq-9h9m","Warn: Project is vulnerable to: PYSEC-2023-102","Warn: Project is vulnerable to: PYSEC-2023-114"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 8 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-16T09:28:40.207Z","repository_id":45240652,"created_at":"2025-08-16T09:28:40.207Z","updated_at":"2025-08-16T09:28:40.207Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280319063,"owners_count":26310347,"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","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["data-science","linear-algebra","multiway","numerical-analysis","pca","python","scientific-computing","spatio-temporal","tca","tcam","tensor","tensor-algebra","tensor-decomposition","tensor-factorization","tensor-product","time-series-analysis"],"created_at":"2025-10-21T19:19:41.977Z","updated_at":"2025-10-21T19:19:47.088Z","avatar_url":"https://github.com/UriaMorP.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mprod_package\n\n[![Build and test](https://github.com/UriaMorP/mprod_package/actions/workflows/build.yaml/badge.svg)](https://github.com/UriaMorP/mprod_package/actions/workflows/build.yaml)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/mprod-package)\n[![Documentation Status](https://readthedocs.org/projects/mprod-package/badge/?version=latest)](https://mprod-package.readthedocs.io/en/latest/?badge=latest)\n![Conda](https://img.shields.io/conda/dn/conda-forge/mprod-package?label=downloads%28conda-forge%29)\n[![Conda Version](https://img.shields.io/conda/vn/conda-forge/mprod-package.svg)](https://anaconda.org/conda-forge/mprod-package)\n[![Pypi Downloads](https://img.shields.io/pypi/dm/mprod-package.svg?label=Pypi%20downloads)](\nhttps://pypi.org/project/mprod-package/)\n\n\nSoftware implementation for tensor-tensor m-product framework [[1]](#1).\nThe library currently contains tubal QR and tSVDM decompositions, and the TCAM method for dimensionality reduction.\n\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"80%\",height=\"80%\",  src=\"https://user-images.githubusercontent.com/16097812/143407367-36c30aa4-da1f-4a8b-93db-470114486064.png\" /\u003e\n\u003c/p\u003e\n\n## Installation \n\n### Conda\nThe `mprod-package` is hosted in [conda-forge](https://conda-forge.org/) channel. \n\n```\nconda install -c conda-forge mprod-package\n```\n\n### pip\n```\npip install mprod-package \n```\nSee `mprod-package`s [pypi entry](https://pypi.org/project/mprod-package/)\n\n### From source \n\n* Make sure that all dependencies listed in `requirements.txt` file are installed . \n* Clone the repository, then from the package directory, run\n```\npip install -e .\n```\n\nThe dependencies in `requirements.txt` are stated with exact versions used for locally test `mprod-package`, these packages were obtained from conda-forge channel.\n\n```python\nimport pandas as pd\n\nfile_path = \"https://raw.githubusercontent.com/UriaMorP/\" \\\n            \"tcam_analysis_notebooks/main/Schirmer2018/Schirmer2018.tsv\"\n\ndata_table = pd.read_csv(file_path, index_col=[0,1], sep=\"\\t\"\n                       , dtype={'Week':int})\ndata_table = data_table.loc[:,data_table.median() \u003e 1e-7]\ndata_table.rename(columns= {k:f\"Fature_{e+1}\" for e,k in enumerate(data_table.columns)}, inplace=True) \ndata_table.shape\n\n%matplotlib inline\n```\n\n## How to use `TCAM`\n\nGiven with a `pandas.DataFrame` of the data as below, with 2-level index, where the first level as subject identifier (mouse, human, image) and the second level of the index denotes sample repetition identity, in this case - the week during experiment, in which the sample was collected.\n\n\n```python\ndisplay(data_table.iloc[:2,:2].round(3))\n\n```\n\n\n\u003ctable border=\"1\" class=\"dataframe\"\u003e\n  \u003cthead\u003e\n    \u003ctr style=\"text-align: right;\"\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003eFature_1\u003c/th\u003e\n      \u003cth\u003eFature_2\u003c/th\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003eSubjectID\u003c/th\u003e\n      \u003cth\u003eWeek\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003e\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003cth rowspan=\"2\" valign=\"top\"\u003eP_10343\u003c/th\u003e\n      \u003cth\u003e0\u003c/th\u003e\n      \u003ctd\u003e0.001\u003c/td\u003e\n      \u003ctd\u003e0.023\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e4\u003c/th\u003e\n      \u003ctd\u003e0.020\u003c/td\u003e\n      \u003ctd\u003e0.000\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n\n### Shape the data into tensor\n\nWe use the `table2tensor` helper function to transform a 2-level (multi)-indexed `pandas.DataFrame` into a 3rd order tensor. \n\n\n```python\nfrom mprod import table2tensor\ndata_tensor, map1, map3 =  table2tensor(data_table)\n```\n\nTo inspect `table2tensor` operation, we use the resulting *\\\"mode mappings\\\"*; `map1` and `map3`  associating each line in the input table to it's coordinates in the resulting tensor.\nIn the following example, we use the mappings to extract the tensor coordinates corresponding to subject P\\_7218's sample from week 52\n\n\n```python\n(data_tensor[map1['P_7218'],:, map3[52]] == data_table.loc[('P_7218',52)].values).all() # True\n```\n\n### Applying `TCAM`\n\n```python\nfrom mprod.dimensionality_reduction import TCAM\n\ntca = TCAM()\ntca_trans = tca.fit_transform(data_tensor)\n```\n\nAnd that's all there is to it... Really!\n\nNote how similar the code above to what we would have written if we were to apply scikit-lean's `PCA` to the initial tabular data:\n\n\n```python\nfrom sklearn.decomposition import PCA\n\npca = PCA()\npca_trans = pca.fit_transform(data_table)\n```\n\nThe similarity between `TCAM`s interface to that of scikit-learn's `PCA` is not coincidental.\nWe did our best in order to make `TCAM` as familiar as possible, and allow for high compatibility of `TCAM` with the existing Python ML framework.\n\n### Accessing properties of the transformation\n\n\n```python\ntca_loadings = tca.mode2_loadings  # Obtain TCAM loadings\npca_loadings = pca.components_     # Obtain PCA loadings\n\ntca_var = tca.explained_variance_ratio_*100 # % explained variation per TCA factor\npca_var = pca.explained_variance_ratio_*100 # % explained variation per TCA factor\n\ntca_df = pd.DataFrame(tca_trans)   # Cast TCA scores to dataframe\ntca_df.rename(index = dict(map(reversed, map1.items()))\n              , inplace = True)    # use the inverse of map1 to denote each row \n                                   # of the TCAM scores with it's subject ID\n    \npca_df = pd.DataFrame(pca_trans)   # Cast PCA scores to dataframe\npca_df.index = data_table.index    # anotate PC scores with sample names\n```\n\n\n\n\n\n## References\n\u003ca id=\"1\"\u003e[1]\u003c/a\u003e \nMisha E. Kilmer, Lior Horesh, Haim Avron, and Elizabeth Newman.  Tensor-tensor algebra for optimal representation and compression of multiway data. Proceedings of the National Academy of Sciences, 118(28):e2015851118, jul 2021.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furiamorp%2Fmprod_package","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Furiamorp%2Fmprod_package","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furiamorp%2Fmprod_package/lists"}