Skip to content

Latest commit

 

History

History
110 lines (82 loc) · 2.23 KB

README.md

File metadata and controls

110 lines (82 loc) · 2.23 KB

Install

This is a python 3 verson of Rupy's GCCA.

Install: pip install git+https://github.com/rjadr/GCCA

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 gcca.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.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!