Skip to content

TensorClus, Tensor co-clustering, text mining, clustering, multiple graphs

License

Notifications You must be signed in to change notification settings

boutalbi/TensorClus

Repository files navigation

TensorClus

Documentation Status PyPI version

TensorClus (Tensor Clustering) is the first Python library aiming to cluster and co-clustering tensor data. It allows to easily perform tensor clustering through 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.

About

TensorClus, Tensor co-clustering, text mining, clustering, multiple graphs

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published