semvec/pypi-packages huggingface dataset:
KTensors 0.1.7
K-Tensors
License: MIT
Keywords: KTensors: Clustering Positive Semi-Denfinite Matrices

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.
jmessaging 0.3.0
Make printing colorized messages to terminal easier
License: MIT

# jmessaging

`jmessaging` is a very simple package (with no dependencies!) that makes
printing colorized messages to the console a breeze.

## Usage

```python
import jmessaging as jm

messenger = jm.Messenger()
messenger.info('This is a message')
messenger.warning('This is a warning')
messenger.error('This is an error')
```

would result in

![Example default output][output example]

### Changing the brackets and text color

The brackets around the message type can be changed along with the color
associated with the type

```python
import jmessaging as jm

messenger = jm.Messenger()

messenger._left = '<'
messenger._right = '>'

messenger._info = jm.jcolor.blue + jm.jstyle.bold
messenger._warning = jm.jcolor.magenta + jm.jstyle.bold
messenger._error = jm.jcolor.green + jm.jstyle.bold

messenger.info('This is a message')
messenger.warning('This is a warning')
messenger.error('This is an error')
```
would result in

![Example modified output][output modified]

### Changing background color

```python
import jmessaging as jm

messenger = jm.Messenger()
messenger._info = jm.jbackground.black + jm.jcolor.white + jm.jstyle.bold
messenger._warning = jm.jbackground.yellow + jm.jcolor.white + jm.jstyle.bold
messenger._error = jm.jbackground.red + jm.jcolor.white + jm.jstyle.bold

messenger.info('This is a message')
messenger.warning('This is a warning')
messenger.error('This is an error')
```

would result in

![Example of modified background][output background]


### Colorizing text

Text can be colorized using the `jcolorize` function from the `jcolor` module
like so

```python
import jmessaging as jm

colorized = jm.jcolorize('This is text', jm.jcolor.cyan)
print(colorized)
```

would result in

![Example of colorized text][output colorized]

### Printing on the same line

You can print on the same line repeatedly using the `print_same_line` function
like so

```python
import time
import jmessaging as jm

for i in range(1000, 0, -1):
    jm.print_same_line(f'Current num: {i}')
    time.sleep(0.001)

print('\n')
```

would result in

![Example of printing on the same line][output same line]

Notice the `print('\n')` at the end. That's necessary (or use `print()`) to move
the cursor to the next line.

[output example]: https://raw.githubusercontent.com/jay3ss/jmessaging/main/docs/output-example.png
[output modified]: https://raw.githubusercontent.com/jay3ss/jmessaging/main/docs/output-modified.png
[output background]: https://raw.githubusercontent.com/jay3ss/jmessaging/main/docs/output-background.png
[output colorized]: https://raw.githubusercontent.com/jay3ss/jmessaging/main/docs/output-colorized.png
[output same line]: https://raw.githubusercontent.com/jay3ss/jmessaging/main/docs/output-same-line.gif