Skip to main content

TensorClus is a Python package for clustering of three-way tensor data

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

TensorClus-0.0.2.tar.gz (22.8 kB view details)

Uploaded Source

Built Distribution

TensorClus-0.0.2-py3-none-any.whl (37.7 kB view details)

Uploaded Python 3

File details

Details for the file TensorClus-0.0.2.tar.gz.

File metadata

  • Download URL: TensorClus-0.0.2.tar.gz
  • Upload date:
  • Size: 22.8 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for TensorClus-0.0.2.tar.gz
Algorithm Hash digest
SHA256 0bcb4e7694fe8b8f07d7b5609ef3b1b88034cfcb7dcd873f262c678d425dc2b5
MD5 d5f0dc112b4cdae4e30510ef301aaefc
BLAKE2b-256 1e55ab3492be235d7ad55456b648a35c60cca4c074ba857655a2831db095e247

See more details on using hashes here.

File details

Details for the file TensorClus-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: TensorClus-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 37.7 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for TensorClus-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ff1bcdf7b7c3d774d9eaf237ec436a9a372993903e8c108993b007c7627ddca6
MD5 973715198f9c43c234e4e48511bb3403
BLAKE2b-256 24dd0955de1d605ffdbf8a576d92a55ace2a8aaea151b691da4ebbc4a9f651d5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page