Skip to main content

K-Tensors: Clustering Positive Semi-Definite Matrices

Project Status: Active Build Status codecov CRAN_Status_Badge CRAN_Download_Badge

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.

Metadata

Release files for KTensors 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for KTensors 0.1.7
File Size Uploaded
KTensors-0.1.7.tar.gz 3.8 kB Details

Release files / KTensors-0.1.7.tar.gz

Download URL KTensors-0.1.7.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
29d9d111112fbfb67bd06d6e4c3ee6d4ee1d0677036185cb0297d72f2dcbc1a6
BLAKE2b-256 checksum
How to use checksums
316384f3dbca49f7898bbe6f43634aa29ea8992a31f8615c1a84ef11714747f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.11

Release history Release notifications | RSS feed

This release

0.1.7 This release

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.6

3 release files

0.0.5

2 release files

0.0.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page