KTensors


NameKTensors JSON
Version 0.1.7 PyPI version JSON
download
home_pagehttps://github.com/Hanchao-Zhang/KTensors
SummaryK-Tensors
upload_time2023-06-13 00:56:56
maintainer
docs_urlNone
authorHanchao Zhang
requires_python
licenseMIT
keywords ktensors: clustering positive semi-denfinite matrices
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            K-Tensors: Clustering Positive Semi-Definite Matrices<img src="./ktensorlogo.png" align="right" width="150" />
========================================================================================================================


[![Project Status:
Active](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) [![Build
Status](https://travis-ci.org/stephenslab/clusteringCPC.svg?branch=master)](https://travis-ci.org/stephenslab/clusteringCPC) [![codecov](https://codecov.io/gh/stephenslab/clusteringCPC/branch/master/graph/badge.svg)](https://codecov.io/gh/stephenslab/clusteringCPC) [![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/clusteringCPC)](https://cran.r-project.org/package=clusteringCPC) [![CRAN\_Download\_Badge](http://cranlogs.r-pkg.org/badges/clusteringCPC)](https://cran.r-project.org/package=clusteringCPC)

## Install the Package from PyPI
+ Go to the terminal (mac) or command line (windows), copy and paste:`pip3 install KTensors` or `pip3 install KTensors==0.1.7` for a specific version

## install the Package from GitHub

+ Go to the terminal (mac) or command line (windows), copy and paste:`pip3 install git+https://github.com/Hanchao-Zhang/KTensors.git`
+ Open a python console, copy and paste: `from KTensors import KTensors`


## About the Package

### `KTensors`

`KTensors(Psis, K, max_iter=1000).clustering()`

input:
- Psis: a 3D array of size (n, p, p) where n is the number of matrices and p is the dimension of the positive semi-definite matrices.
- K: number of clusters
- max_iter: maximum number of iterations, default is 1000, usually finish within 10 iterations

return:
- group: a vector of length n, each element is an index of group membership
- CPCs: K orthonormal basis matrices of size p by p for each cluster
- $\mathbf F$: $\mathbf F = \mathbf B^\top \mathbf\Psi \mathbf B$
- $\text{diag}(\mathbf F)$: $\text{diag}(\mathbf F) = (\mathbf B^\top \mathbf\Psi \mathbf B) \circ \mathbf I$ the diagonal of matrix $\mathbf F$
- centers: Mean of each cluster
- loss: loss function for each iteration

### `KMetrics`

`KMetrics(Psis, K, metrics)`
input:
- Psis: a 3D array of size (n, p, p) where n is the number of matrices and p is the dimension of the positive semi-definite matrices.
- K: number of clusters
- metrics: a string of metrics, including 'euclidean', 'affine_invariant', 'log_euclidean', 'log_det', and 'symmetric_stein'.

output:
- a vector of length n, each element is an index of group membership
- loss function for each iteration

## Some Tecnical Details

### Loss Function

$$\begin{aligned}\mathcal L(\mathbf \Psi, \mathcal P_{\mathbf B} (\mathbf \Psi) )  = \Vert \mathbf \Psi - \mathbf B((\mathbf B^\top \mathbf \Psi \mathbf B) \circ \mathbb I )\mathbf B^\top \Vert_F^2 = \Vert\mathbf B^\top \mathbf \Psi \mathbf B - (\mathbf B^\top \mathbf \Psi \mathbf B)\circ \mathbb I \Vert_F^2 \end{aligned}$$

where $\mathbb I$ is a identity matrix, and $\circ$ is the Hadamard product.

For more technical details, please refer to the paper. 


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Hanchao-Zhang/KTensors",
    "name": "KTensors",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "KTensors: Clustering Positive Semi-Denfinite Matrices",
    "author": "Hanchao Zhang",
    "author_email": "hz1641@nyu.edu",
    "download_url": "https://files.pythonhosted.org/packages/31/63/84f3dbca49f7898bbe6f43634aa29ea8992a31f8615c1a84ef11714747f8/KTensors-0.1.7.tar.gz",
    "platform": null,
    "description": "K-Tensors: Clustering Positive Semi-Definite Matrices<img src=\"./ktensorlogo.png\" align=\"right\" width=\"150\" />\n========================================================================================================================\n\n\n[![Project Status:\nActive](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) [![Build\nStatus](https://travis-ci.org/stephenslab/clusteringCPC.svg?branch=master)](https://travis-ci.org/stephenslab/clusteringCPC) [![codecov](https://codecov.io/gh/stephenslab/clusteringCPC/branch/master/graph/badge.svg)](https://codecov.io/gh/stephenslab/clusteringCPC) [![CRAN\\_Status\\_Badge](http://www.r-pkg.org/badges/version/clusteringCPC)](https://cran.r-project.org/package=clusteringCPC) [![CRAN\\_Download\\_Badge](http://cranlogs.r-pkg.org/badges/clusteringCPC)](https://cran.r-project.org/package=clusteringCPC)\n\n## Install the Package from PyPI\n+ Go to the terminal (mac) or command line (windows), copy and paste:`pip3 install KTensors` or `pip3 install KTensors==0.1.7` for a specific version\n\n## install the Package from GitHub\n\n+ Go to the terminal (mac) or command line (windows), copy and paste:`pip3 install git+https://github.com/Hanchao-Zhang/KTensors.git`\n+ Open a python console, copy and paste: `from KTensors import KTensors`\n\n\n## About the Package\n\n### `KTensors`\n\n`KTensors(Psis, K, max_iter=1000).clustering()`\n\ninput:\n- Psis: a 3D array of size (n, p, p) where n is the number of matrices and p is the dimension of the positive semi-definite matrices.\n- K: number of clusters\n- max_iter: maximum number of iterations, default is 1000, usually finish within 10 iterations\n\nreturn:\n- group: a vector of length n, each element is an index of group membership\n- CPCs: K orthonormal basis matrices of size p by p for each cluster\n- $\\mathbf F$: $\\mathbf F = \\mathbf B^\\top \\mathbf\\Psi \\mathbf B$\n- $\\text{diag}(\\mathbf F)$: $\\text{diag}(\\mathbf F) = (\\mathbf B^\\top \\mathbf\\Psi \\mathbf B) \\circ \\mathbf I$ the diagonal of matrix $\\mathbf F$\n- centers: Mean of each cluster\n- loss: loss function for each iteration\n\n### `KMetrics`\n\n`KMetrics(Psis, K, metrics)`\ninput:\n- Psis: a 3D array of size (n, p, p) where n is the number of matrices and p is the dimension of the positive semi-definite matrices.\n- K: number of clusters\n- metrics: a string of metrics, including 'euclidean', 'affine_invariant', 'log_euclidean', 'log_det', and 'symmetric_stein'.\n\noutput:\n- a vector of length n, each element is an index of group membership\n- loss function for each iteration\n\n## Some Tecnical Details\n\n### Loss Function\n\n$$\\begin{aligned}\\mathcal L(\\mathbf \\Psi, \\mathcal P_{\\mathbf B} (\\mathbf \\Psi) )  = \\Vert \\mathbf \\Psi - \\mathbf B((\\mathbf B^\\top \\mathbf \\Psi \\mathbf B) \\circ \\mathbb I )\\mathbf B^\\top \\Vert_F^2 = \\Vert\\mathbf B^\\top \\mathbf \\Psi \\mathbf B - (\\mathbf B^\\top \\mathbf \\Psi \\mathbf B)\\circ \\mathbb I \\Vert_F^2 \\end{aligned}$$\n\nwhere $\\mathbb I$ is a identity matrix, and $\\circ$ is the Hadamard product.\n\nFor more technical details, please refer to the paper. \n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "K-Tensors",
    "version": "0.1.7",
    "project_urls": {
        "Homepage": "https://github.com/Hanchao-Zhang/KTensors"
    },
    "split_keywords": [
        "ktensors:",
        "clustering",
        "positive",
        "semi-denfinite",
        "matrices"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "316384f3dbca49f7898bbe6f43634aa29ea8992a31f8615c1a84ef11714747f8",
                "md5": "879a15d93f98e4dedb6aab7ffe91a794",
                "sha256": "29d9d111112fbfb67bd06d6e4c3ee6d4ee1d0677036185cb0297d72f2dcbc1a6"
            },
            "downloads": -1,
            "filename": "KTensors-0.1.7.tar.gz",
            "has_sig": false,
            "md5_digest": "879a15d93f98e4dedb6aab7ffe91a794",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3782,
            "upload_time": "2023-06-13T00:56:56",
            "upload_time_iso_8601": "2023-06-13T00:56:56.864770Z",
            "url": "https://files.pythonhosted.org/packages/31/63/84f3dbca49f7898bbe6f43634aa29ea8992a31f8615c1a84ef11714747f8/KTensors-0.1.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-13 00:56:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Hanchao-Zhang",
    "github_project": "KTensors",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "ktensors"
}
        
Elapsed time: 0.07709s