Skip to main content

TensorClus

Documentation Status PyPI version

TensorClus (Tensor Clustering) is a first Python library aiming to clustering and co-clustering of tensor data. It allows to easily perform tensor clustering throught decomposition or tensor learning and tensor algebra. TensorClus allows easy interaction with other python packages such as NumPy, Tensorly, TensorFlow or TensorD, and run methods at scale on CPU or GPU.

It supports major operating systems namely Microsoft Windows, MacOS, and Ubuntu.

N|Solid

Brief description

TensorClus library provides multiple functionalities:

  • Several datasets
  • Tensor co-clustering with various data type
  • Tensor decomposition and clustering
  • Visualization

Requirements

numpy==1.18.3
pandas==1.0.3
scipy==1.4.1
matplotlib==3.0.3
scikit-learn==0.22.2.post1
coclust==0.2.1
tensorD==0.1
tensorflow==2.3.0
tensorflow-gpu==2.3.0
tensorflow-estimator==2.3.0
tensorly==0.4.5

Installing TensorClus

For installing TensorClus package use the following command

pip install -U TensorClus

To clone TensorClus project from github

# Install git LFS via https://www.atlassian.com/git/tutorials/git-lfs
# initialize Git LFS
git lfs install Git LFS initialized.
git init Initialized
# clone the repository
git clone https://github.com/boutalbi/TensorClus.git
cd TensorClus
# Install in editable mode with `-e` or, equivalently, `--editable`
pip install -e .

For more details about TensorClus, see Documentation.

License

TensorClus is released under the MIT License (refer to LISENSE file for details).

Examples

import TensorClus.coclustering.sparseTensorCoclustering as tcSCoP
from TensorClus.reader import load
import numpy as np
from coclust.evaluation.external import accuracy

##################################################################
# Load DBLP1 dataset #
##################################################################
data_v2, labels, slices = load.load_dataset("DBLP1_dataset")
n = data_v2.shape[0]
##################################################################
# Execute TSPLBM on the dataset #
##################################################################

# Define the number of clusters K 
K = 3

# Optional: initialization of rows and columns partitions
z=np.zeros((n,K))
z_a=np.random.randint(K,size=n)
z=np.zeros((n,K))+ 1.e-9
z[np.arange(n) , z_a]=1
w=np.asarray(z)


# Run TSPLBM 

model = tcSCoP.SparseTensorCoclusteringPoisson(n_clusters=K , fuzzy = True,init_row=z, init_col=w,max_iter=50)
model.fit(data_v2)
predicted_row_labels = model.row_labels_
predicted_column_labels = model.column_labels_

acc = np.around(accuracy(labels, predicted_row_labels),3)
print("Accuracy : ", acc)

Datasets

The following datasets and their description are available in Google Drive.

References

[1] Boutalbi, R., Labiod, L., & Nadif, M. (2020). Tensor latent block model for co-clustering. International Journal of Data Science and Analytics, 1-15.

[2] Boutalbi, R., Labiod, L., & Nadif, M. (2019, July). Sparse Tensor Co-clustering as a Tool for Document Categorization. In Proceedings of the 42nd International ACM SIGIR Conference on Research and Development in Information Retrieval (pp. 1157-1160).

[3] Boutalbi, R., Labiod, L., & Nadif, M. (2019, April). Co-clustering from Tensor Data. In Pacific-Asia Conference on Knowledge Discovery and Data Mining (pp. 370-383). Springer.

Metadata

Release files for TensorClus 0.0.2

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

Source distribution (sdist)

Source distribution for TensorClus 0.0.2
File Size Uploaded
TensorClus-0.0.2.tar.gz 22.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for TensorClus 0.0.2
File Interpreter ABI Platform
TensorClus-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 60.5 kB

Release files / TensorClus-0.0.2.tar.gz

Download URL TensorClus-0.0.2.tar.gz
Size 22.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0bcb4e7694fe8b8f07d7b5609ef3b1b88034cfcb7dcd873f262c678d425dc2b5
BLAKE2b-256 checksum
How to use checksums
1e55ab3492be235d7ad55456b648a35c60cca4c074ba857655a2831db095e247
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.7

Release files / TensorClus-0.0.2-py3-none-any.whl

Download URL TensorClus-0.0.2-py3-none-any.whl
Size 37.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ff1bcdf7b7c3d774d9eaf237ec436a9a372993903e8c108993b007c7627ddca6
BLAKE2b-256 checksum
How to use checksums
24dd0955de1d605ffdbf8a576d92a55ace2a8aaea151b691da4ebbc4a9f651d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.7

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

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