Skip to main content
Tests Coverage Documentation Status https://img.shields.io/badge/code%20style-black-000000.svg

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.7 or above (it may also work with Python 3.6, 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 tlviz

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

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:

  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. and 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.

Metadata

Release files for TLViz 0.1.1

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

Source distribution (sdist)

Source distribution for TLViz 0.1.1
File Size Uploaded
TLViz-0.1.1.tar.gz 632.4 kB Details

Built distribution (wheel)

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

Total release size: 1.3 MB

Release files / TLViz-0.1.1.tar.gz

Download URL TLViz-0.1.1.tar.gz
Size 632.4 kB
Tags Source
SHA-256 checksum
How to use checksums
72835c38fedf02290bf0b7540def77a756a2b0389a91373365610e7cd985a93b
BLAKE2b-256 checksum
How to use checksums
cf7f75eae7aa41373373ba64a28fb89a89761f66fb12f7e7c72cb98d6be0085a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.13

Release files / TLViz-0.1.1-py2.py3-none-any.whl

Download URL TLViz-0.1.1-py2.py3-none-any.whl
Size 701.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
1d221a1e47a4227dcb34c2f934c9dfe39dc840429607d1e6c107fc55a61c217b
BLAKE2b-256 checksum
How to use checksums
abaed98edec8984dbd12d99b4cf8acb12f1c873cf34a9896bb4894321457803d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.13

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

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