tensorly-viz


Nametensorly-viz JSON
Version 0.1.7 PyPI version JSON
download
home_pagehttps://tensorly.org/viz
SummaryPackage to visualise component-based decomposition models such as PCA and PARAFAC
upload_time2023-01-20 16:19:05
maintainer
docs_urlNone
authorMarie Roald & Yngve Mardal Moe
requires_python
license"MIT license",
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ==================================================
TLViz — Visualising and analysing component models
==================================================

.. image:: https://github.com/tensorly/viz/workflows/tests/badge.svg
    :target: https://github.com/tensorly/viz/actions/workflows/tests.yml
    :alt: Tests Status

.. image:: https://codecov.io/gh/tensorly/viz/branch/main/graph/badge.svg?token=QhgCjtr2qk
    :target: https://codecov.io/gh/tensorly/viz
    :alt: Coverage Status

.. image:: https://github.com/tensorly/viz/actions/workflows/build_doc.yml/badge.svg
    :target: https://github.com/tensorly/viz/actions/workflows/build_doc.yml
    :alt: Documentation Status

.. image:: https://zenodo.org/badge/354456143.svg
   :target: https://zenodo.org/badge/latestdoi/354456143
   :alt: Zenodo DOI

.. image:: https://joss.theoj.org/papers/10.21105/joss.04754/status.svg
    :target: https://doi.org/10.21105/joss.04754
    :alt: JOSS | 10.21105/joss.04754

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
    :target: https://github.com/psf/black
    :alt: 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 <https://tensorly.org/viz>`_ and includes

* A `primer on tensors <http://tensorly.org/viz/stable/about_tensors.html#>`_, `tensor factorisations <http://tensorly.org/viz/stable/about_tensors.html#what-are-tensor-factorisations>`_ and the `notation we use <http://tensorly.org/viz/stable/about_tensors.html#notation>`_
* `An example gallery <http://tensorly.org/viz/stable/auto_examples/index.html>`_
* `The API reference <http://tensorly.org/viz/stable/api.html>`_


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:

.. code:: raw

    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 <https://pingouin-stats.org>`_.

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

.. code:: raw

    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 <https://tensorly.org/viz/stable/installation.html>`_.

Example
-------

.. code:: python

    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()

.. code:: raw

    Loading Aminoacids dataset from:
    Bro, R, PARAFAC: Tutorial and applications, Chemometrics and Intelligent Laboratory Systems, 1997, 38, 149-171

.. image:: docs/figures/readme_example.svg
    :width: 800
    :alt: 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:

#. 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.
#. Plot the components using matplotlib.

All these steps are described in the `API documentation <https://tensorly.org/viz/stable/api.html>`_ with references to the literature.

Testing
-------

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

.. code:: raw

    pip install tlviz[test]

or

.. code:: raw

    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 <http://tensorly.org/viz/stable/contributing.html>`_.



            

Raw data

            {
    "_id": null,
    "home_page": "https://tensorly.org/viz",
    "name": "tensorly-viz",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Marie Roald & Yngve Mardal Moe",
    "author_email": "roald.marie@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/34/5f/3fbf40d70f417b63120b153e15048b238862b754aa317df8ac19360223e0/tensorly-viz-0.1.7.tar.gz",
    "platform": null,
    "description": "==================================================\nTLViz \u2014 Visualising and analysing component models\n==================================================\n\n.. image:: https://github.com/tensorly/viz/workflows/tests/badge.svg\n    :target: https://github.com/tensorly/viz/actions/workflows/tests.yml\n    :alt: Tests Status\n\n.. image:: https://codecov.io/gh/tensorly/viz/branch/main/graph/badge.svg?token=QhgCjtr2qk\n    :target: https://codecov.io/gh/tensorly/viz\n    :alt: Coverage Status\n\n.. image:: https://github.com/tensorly/viz/actions/workflows/build_doc.yml/badge.svg\n    :target: https://github.com/tensorly/viz/actions/workflows/build_doc.yml\n    :alt: Documentation Status\n\n.. image:: https://zenodo.org/badge/354456143.svg\n   :target: https://zenodo.org/badge/latestdoi/354456143\n   :alt: Zenodo DOI\n\n.. image:: https://joss.theoj.org/papers/10.21105/joss.04754/status.svg\n    :target: https://doi.org/10.21105/joss.04754\n    :alt: JOSS | 10.21105/joss.04754\n\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n    :target: https://github.com/psf/black\n    :alt: Code style: Black\n\nTLViz is a Python package for visualising component-based decomposition models like PARAFAC and PCA.\n\nDocumentation\n-------------\n\nThe documentation\nis available on `the TensorLy website <https://tensorly.org/viz>`_ and includes\n\n* A `primer on tensors <http://tensorly.org/viz/stable/about_tensors.html#>`_, `tensor factorisations <http://tensorly.org/viz/stable/about_tensors.html#what-are-tensor-factorisations>`_ and the `notation we use <http://tensorly.org/viz/stable/about_tensors.html#notation>`_\n* `An example gallery <http://tensorly.org/viz/stable/auto_examples/index.html>`_\n* `The API reference <http://tensorly.org/viz/stable/api.html>`_\n\n\nDependencies\n------------\n\nTLViz supports Python 3.8 or above (it may also work with Python 3.6 and 3.7, though that is not officially supported).\n\nInstallation requires matplotlib, numpy, pandas, scipy, statsmodels and xarray.\n\nInstallation\n------------\n\nTo install the latest stable release of TLViz and its dependencies, run:\n\n.. code:: raw\n\n    pip install tensorly-viz\n\nThere is also functionality to create improved QQ-plots with Pingoiun.\nHowever, this is disabled by default due to the restrictive GPL lisence.\nTo enable this possibility, you must manually `install Pingoiun <https://pingouin-stats.org>`_.\n\nTo install the latest development version of TLViz, you can either clone\nthis repo or run\n\n.. code:: raw\n\n    pip install git+https://github.com/marieroald/tlviz.git\n\n\nSome extra dependencies are needed to run the examples, tests or build the documentation.\nFor more information about installing these dependencies, see the `installation guide <https://tensorly.org/viz/stable/installation.html>`_.\n\nExample\n-------\n\n.. code:: python\n\n    import tlviz\n    import matplotlib.pyplot as plt\n    from tensorly.decomposition import parafac\n\n    def fit_parafac(dataset, num_components, num_inits):\n        model_candidates = [\n            parafac(dataset.data, num_components, init=\"random\", random_state=i)\n            for i in range(num_inits)\n        ]\n        model = tlviz.multimodel_evaluation.get_model_with_lowest_error(\n            model_candidates, dataset\n        )\n        return tlviz.postprocessing.postprocess(model, dataset)\n\n    data = tlviz.data.load_aminoacids()\n    cp_tensor = fit_parafac(data, 3, num_inits=3)\n    tlviz.visualisation.components_plot(cp_tensor)\n    plt.show()\n\n.. code:: raw\n\n    Loading Aminoacids dataset from:\n    Bro, R, PARAFAC: Tutorial and applications, Chemometrics and Intelligent Laboratory Systems, 1997, 38, 149-171\n\n.. image:: docs/figures/readme_example.svg\n    :width: 800\n    :alt: An example figure showing the component vectors of a three component PARAFAC model fitted to a fluoresence spectroscopy dataset.\n\nThis example uses TensorLy to fit five three-component PARAFAC models to the data. Then it uses TLViz to do the following steps:\n\n#. Select the model that gave the lowest reconstruction error.\n#. Normalise the component vectors, storing their magnitude in a separate weight-vector.\n#. Permute the components in descending weight (i.e. signal strength) order.\n#. Flip the components so they point in a logical direction compared to the data.\n#. Convert the factor matrices into Pandas DataFrames with logical indices.\n#. Plot the components using matplotlib.\n\nAll these steps are described in the `API documentation <https://tensorly.org/viz/stable/api.html>`_ with references to the literature.\n\nTesting\n-------\n\nThe test suite requires an additional set of dependencies. To install these, run\n\n.. code:: raw\n\n    pip install tlviz[test]\n\nor\n\n.. code:: raw\n\n    pip install -e .[test]\n\ninside your local copy of the TLViz repository.\n\nThe tests can be run by calling ``pytest`` with no additional arguments.\nAll doctests are ran by default and a coverage summary will be printed on the screen.\nTo generate a coverage report, run ``coverage html``.\n\nContributing\n------------\n\nContributions are welcome to TLViz, see the `contribution guidelines <http://tensorly.org/viz/stable/contributing.html>`_.\n\n\n",
    "bugtrack_url": null,
    "license": "\"MIT license\",",
    "summary": "Package to visualise component-based decomposition models such as PCA and PARAFAC",
    "version": "0.1.7",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d089c7712a15477a0b7577603036c7a4a23ca7dcff75b56f598dcded6c444bda",
                "md5": "efef4c7a0838fa30dc87b73cfaf517f1",
                "sha256": "5036c64dd8d561f148c6ebe26ad5edd4cfc4e00aa84f9703505de7a28bc70d59"
            },
            "downloads": -1,
            "filename": "tensorly_viz-0.1.7-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "efef4c7a0838fa30dc87b73cfaf517f1",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 701994,
            "upload_time": "2023-01-20T16:19:03",
            "upload_time_iso_8601": "2023-01-20T16:19:03.656053Z",
            "url": "https://files.pythonhosted.org/packages/d0/89/c7712a15477a0b7577603036c7a4a23ca7dcff75b56f598dcded6c444bda/tensorly_viz-0.1.7-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "345f3fbf40d70f417b63120b153e15048b238862b754aa317df8ac19360223e0",
                "md5": "8f1f6496d0d97cedf7a187aaea520491",
                "sha256": "43c9bd02b6ea5fa33ffc78a54b5f3a934dff2406ac8a3727ed0d48eea5681440"
            },
            "downloads": -1,
            "filename": "tensorly-viz-0.1.7.tar.gz",
            "has_sig": false,
            "md5_digest": "8f1f6496d0d97cedf7a187aaea520491",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 633159,
            "upload_time": "2023-01-20T16:19:05",
            "upload_time_iso_8601": "2023-01-20T16:19:05.730164Z",
            "url": "https://files.pythonhosted.org/packages/34/5f/3fbf40d70f417b63120b153e15048b238862b754aa317df8ac19360223e0/tensorly-viz-0.1.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-20 16:19:05",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "tensorly-viz"
}
        
Elapsed time: 0.06203s