Skip to main content
Tests Status Coverage Status Documentation Status Zenodo DOI JOSS | 10.21105/joss.04754 Code style: Black

TLViz is a Python package for visualising component-based decomposition models like PARAFAC and PCA.

Documentation

The documentation is available on the TensorLy website and includes

Dependencies

TLViz supports Python 3.8 or above (it may also work with Python 3.6 and 3.7, though that is not officially supported).

Installation requires matplotlib, numpy, pandas, scipy, statsmodels and xarray.

Installation

To install the latest stable release of TLViz and its dependencies, run:

pip install tensorly-viz

There is also functionality to create improved QQ-plots with Pingoiun. However, this is disabled by default due to the restrictive GPL lisence. To enable this possibility, you must manually install Pingoiun.

To install the latest development version of TLViz, you can either clone this repo or run

pip install git+https://github.com/marieroald/tlviz.git

Some extra dependencies are needed to run the examples, tests or build the documentation. For more information about installing these dependencies, see the installation guide.

Example

import tlviz
import matplotlib.pyplot as plt
from tensorly.decomposition import parafac

def fit_parafac(dataset, num_components, num_inits):
    model_candidates = [
        parafac(dataset.data, num_components, init="random", random_state=i)
        for i in range(num_inits)
    ]
    model = tlviz.multimodel_evaluation.get_model_with_lowest_error(
        model_candidates, dataset
    )
    return tlviz.postprocessing.postprocess(model, dataset)

data = tlviz.data.load_aminoacids()
cp_tensor = fit_parafac(data, 3, num_inits=3)
tlviz.visualisation.components_plot(cp_tensor)
plt.show()
Loading Aminoacids dataset from:
Bro, R, PARAFAC: Tutorial and applications, Chemometrics and Intelligent Laboratory Systems, 1997, 38, 149-171
An example figure showing the component vectors of a three component PARAFAC model fitted to a fluoresence spectroscopy dataset.

This example uses TensorLy to fit five three-component PARAFAC models to the data. Then it uses TLViz to do the following steps:

  1. Select the model that gave the lowest reconstruction error.

  2. Normalise the component vectors, storing their magnitude in a separate weight-vector.

  3. Permute the components in descending weight (i.e. signal strength) order.

  4. Flip the components so they point in a logical direction compared to the data.

  5. Convert the factor matrices into Pandas DataFrames with logical indices.

  6. Plot the components using matplotlib.

All these steps are described in the API documentation with references to the literature.

Testing

The test suite requires an additional set of dependencies. To install these, run

pip install tlviz[test]

or

pip install -e .[test]

inside your local copy of the TLViz repository.

The tests can be run by calling pytest with no additional arguments. All doctests are ran by default and a coverage summary will be printed on the screen. To generate a coverage report, run coverage html.

Contributing

Contributions are welcome to TLViz, see the contribution guidelines.

Release files for tensorly-viz 0.1.8

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

Source distribution (sdist)

Source distribution for tensorly-viz 0.1.8
File Size Uploaded
tensorly_viz-0.1.8.tar.gz 653.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tensorly-viz 0.1.8
File Interpreter ABI Platform
tensorly_viz-0.1.8-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 1.4 MB

Release files / tensorly_viz-0.1.8.tar.gz

Download URL tensorly_viz-0.1.8.tar.gz
Size 653.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ab5ac34b269be0623353a213e5e01729c253893891842d613503f76d7f70838a
BLAKE2b-256 checksum
How to use checksums
6b5ecff2aaf8acd1498b2c787546104e2a1e4dc5153bc05640e3f1ff39561952
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.13

Release files / tensorly_viz-0.1.8-py2.py3-none-any.whl

Download URL tensorly_viz-0.1.8-py2.py3-none-any.whl
Size 702.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
1178ab5d79ae6dbbfb3a9511829d5e0f4502b43914cf305319b0308320d2f11f
BLAKE2b-256 checksum
How to use checksums
b39e9a5386e62e859f3fba6a0b86181d0ddd639dc84e3693902a706100e3ce9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.13

Release history Release notifications | RSS feed

This release

0.1.8 This release

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

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