Python中的正则化核典型相关分析。
项目描述
pyrcca
Python中的正则化核典型相关分析。
安装
您可以从PyPI安装pyrcca
的最新版本,使用
pip install pyrcca
您可以从GitHub安装pyrcca
的开发版本,使用
pip install git+git://github.com/gallantlab/pyrcca.git
使用方法
以下示例分析的静态Jupyter笔记本可以在此处找到:这里。
以下fMRI数据的Pyrcca分析的静态Jupyter笔记本可以在此处找到:这里。
您可以通过克隆此存储库交互式地探索这两个笔记本。
参考
有关更多信息,请参阅以下e-print出版物:Bilenko, N.Y. and Gallant, J.L. (2015). Pyrcca:Python中的正则化核典型相关分析及其在神经影像学中的应用。Frontiers in Neuroinformatics doi: 10.3389/fninf.2016.00049
示例
在此启动示例中,创建了两个人工构建的数据集。数据集依赖于两个潜在变量。使用Pyrcca查找数据集之间的线性关系。
# 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])
项目详情
下载文件
下载适用于您的平台的文件。如果您不确定该选择哪一个,请了解有关安装软件包的更多信息。
源代码发行版
本发行版没有可用的源代码分发文件。请参阅有关生成分发存档的教程。
构建后的分发版
pyrcca-0.2-py3-none-any.whl (7.4 kB 查看哈希值)