Package to visualise component-based decomposition models such as PCA and PARAFAC
Project description
TLVis is a Python package for visualising component-based decomposition models like PARAFAC and PCA.
Documentation
The documentation is available on ReadTheDocs and includes
Dependencies
TLVis 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 TLVis and its dependencies, run:
pip install tlvis
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 TLVis, you can either clone this repo or run
pip install git+https://github.com/marieroald/tlvis.git
Example
import tlvis
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 = tlvis.multimodel_evaluation.get_model_with_lowest_error(
model_candidates, dataset
)
return tlvis.postprocessing.postprocess(model, dataset)
data = tlvis.data.load_aminoacids()
cp_tensor = fit_parafac(data, 3, num_inits=3)
tlvis.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
This example uses TensorLy to fit five three-component PARAFAC models to the data. Then it uses TLVis to:
Select the model that gave the lowest reconstruction error,
normalise the component vectors, storing their magnitude in a separate weight-vector,
permute the components in descending weight (i.e. signal strength) order,
flip the components so they point in a logical direction compared to the data,
convert the factor matrices into Pandas DataFrames with logical indices,
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 tlvis[test]
or
pip install -e .[test]
inside your local copy of the TLVis 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 TLVis, see the contribution guidelines.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file TLVis-0.0.3.tar.gz
.
File metadata
- Download URL: TLVis-0.0.3.tar.gz
- Upload date:
- Size: 632.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.18.4 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7667525e1023f56087e1fa1671f203d7e61b6938ede0a69fe23fd5ed1e7ba73b |
|
MD5 | f928fa86c3d4328adbefcd8dee96e82e |
|
BLAKE2b-256 | 708f69afcb73660b9216f78c33493b7bdaf4c3735f7ef2597148700fb5098b90 |
File details
Details for the file TLVis-0.0.3-py2.py3-none-any.whl
.
File metadata
- Download URL: TLVis-0.0.3-py2.py3-none-any.whl
- Upload date:
- Size: 701.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.18.4 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9ed257a6f91a362232398e19f36667a66cc57868480dcf4b72e483118cec72b |
|
MD5 | 41b344e56ee2f407cdbdc66299692061 |
|
BLAKE2b-256 | a672a726774759510d3101c543b94a500faa3c92dbc97f743d45bef3fae0952e |