pyrcca
Regularized kernel canonical correlation analysis in Python.
Install
You can install the latest release of pyrcca from PyPI, with:
pip install pyrcca
You can install the development version of pyrcca from GitHub, with:
pip install git+git://github.com/gallantlab/pyrcca.git
Usage
A static Jupyter notebook with the analysis of the example below can be found here.
A static Jupyter notebook with Pyrcca analysis of fMRI data can be found here.
Both notebooks can be explored interactively by cloning this repository.
Reference
For more information, consult the following e-print publication: Bilenko, N.Y. and Gallant, J.L. (2015). Pyrcca: regularized kernel canonical correlation analysis in Python and its applications to neuroimaging. Frontiers in Neuroinformatics doi: 10.3389/fninf.2016.00049
Example
In this startup example, two artificially constructed datasets are created. The datasets depend on two latent variables. Pyrcca is used to find linear relationships between the datasets.
# Imports
import numpy as np
import rcca
# Initialize number of samples
nSamples = 1000
# Define two latent variables (number of samples x 1)
latvar1 = np.random.randn(nSamples,)
latvar2 = np.random.randn(nSamples,)
# Define independent components for each dataset (number of observations x dataset dimensions)
indep1 = np.random.randn(nSamples, 4)
indep2 = np.random.randn(nSamples, 5)
# Create two datasets, with each dimension composed as a sum of 75% one of the latent variables and 25% independent component
data1 = 0.25*indep1 + 0.75*np.vstack((latvar1, latvar2, latvar1, latvar2)).T
data2 = 0.25*indep2 + 0.75*np.vstack((latvar1, latvar2, latvar1, latvar2, latvar1)).T
# Split each dataset into two halves: training set and test set
train1 = data1[:nSamples/2]
train2 = data2[:nSamples/2]
test1 = data1[nSamples/2:]
test2 = data2[nSamples/2:]
# Create a cca object as an instantiation of the CCA object class.
cca = rcca.CCA(kernelcca = False, reg = 0., numCC = 2)
# Use the train() method to find a CCA mapping between the two training sets.
cca.train([train1, train2])
# Use the validate() method to test how well the CCA mapping generalizes to the test data.
# For each dimension in the test data, correlations between predicted and actual data are computed.
testcorrs = cca.validate([test1, test2])
Metadata
Release files for pyrcca 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyrcca-0.2-py3-none-any.whl | Python 3 | none | any | Details for pyrcca-0.2-py3-none-any.whl |
Release files / pyrcca-0.2-py3-none-any.whl
| Download URL | pyrcca-0.2-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
53759703c72da31ad2c4d659ac3e9e5f7996610ab0ff316f0c7494a40ef614e8
|
|
BLAKE2b-256 checksum How to use checksums |
7dc236a2b8334804cd1413f72fe16efc50f5aaa36de5bfdeae79e66f1f35d961
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.1
|
Security for pyrcca 0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.