Generalized Canonical Correlation Analysis
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
gcca
img
save
.gitignore
README.md
setup.py

README.md

GCCA

This repository is implementation of Generalized Canonical Correlation Analysis(GCCA). CCA can use only 2 data but GCCA can use more than 2 data.

CCA

CCA is the method to transform 2 data to one joint space. See example graph:

CCA Plot Result

CCA inplementation contains PCCA (Probablistic Canonical Correlation Analysis) transformation that is assumed that there is latent space in 2 data.

GCCA

GCCA is the method to transform multiple data to one joint space. See example graph:

GCCA Plot Result

You can give GCCA any number of data.

Installation

You can use 'git clone' command to install

Dependencies

You have to install python dependent libraries in advance as follow:

numpy==1.9.1
scipy==0.14.1
matplotlib==1.4.2
h5py==2.4.0

Usage of CCA

from cca import CCA
import logging
import numpy as np

# set log level
logging.root.setLevel(level=logging.INFO)

# create data in advance
a = np.random.rand(50, 50)
b = np.random.rand(50, 60)

# create instance of CCA
cca = CCA()
# calculate CCA
cca.fit(a, b)
# transform
cca.transform(a, b)
# transform by PCCA
cca.ptransform(a, b)
# save
cca.save_params("save/cca.h5")
# load
cca.load_params("save/cca.h5")
# plot
cca.plot_pcca_result()

Usage of GCCA

from gcca import GCCA
import logging
import numpy as np

# set log level
logging.root.setLevel(level=logging.INFO)

# create data in advance
a = np.random.rand(50, 50)
b = np.random.rand(50, 60)
c = np.random.rand(50, 70)
d = np.random.rand(50, 80)
e = np.random.rand(50, 90)
f = np.random.rand(50, 100)
g = np.random.rand(50, 110)
h = np.random.rand(50, 120)
i = np.random.rand(50, 130)
j = np.random.rand(50, 140)
k = np.random.rand(50, 150)

# create instance of GCCA
gcca = GCCA()
# calculate GCCA
gcca.fit(a, b, c, d, e, f, g, h, i, j, k)
# transform
gcca.transform(a, b, c, d, e, f, g, h, i, j, k)
# save
gcca.save_params("save/gcca.h5")
# load
gcca.load_params("save/gcca.h5")
# plot
gcca.plot_gcca_result()

That's it!