CCA results do not match sklearn.cross_decomposition.CCA

Open
#220 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
julia, python

Research direction

Start with the CCA fit(CCA, X, Y; outdim=1) and xtransform(m, X) entry points shown in the report, then compare their outputs with sklearn.cross_decomposition.CCA on the supplied matrices. Determine whether the mismatch is expected or indicates a package issue, and document or test the behavior so reproduction is clear.

Written by the indexing model from the issue text.

Description

Hello,

When using CCA, we (@trappmartin and I) tried to reproduce the results from sklearn.cross_decomposition.CCA

>>> from sklearn.cross_decomposition import CCA
>>> X = [[0., 0., 1.], [1.,0.,0.], [2.,2.,2.], [3.,5.,4.]]
>>> Y = [[0.1, -0.2], [0.9, 1.1], [6.2, 5.9], [11.9, 12.3]]
>>> cca = CCA(n_components=1)
>>> cca.fit(X, Y)
CCA(n_components=1)
>>> X_c, Y_c = cca.transform(X, Y)
>>> X_c
array([[-1.3373174 ],
       [-1.10847164],
       [ 0.40763151],
       [ 2.03815753]])

with the following

julia> Y = reduce(hcat, [[0.1, -0.2], [0.9, 1.1], [6.2, 5.9], [11.9, 12.3]])
julia> X = reduce(hcat, [[0., 0., 1.], [1.,0.,0.], [2.,2.,2.], [3.,5.,4.]])
julia> m = fit(CCA, X, Y; outdim=1)
CCA (xindim = 3, yindim = 2, outdim = 1)
julia> xtransform(m, X)
1×4 Matrix{Float64}:
 0.867677  0.678174  -0.228687  -1.31716

but found out that the results do not match.
We could not figure out if it is due to our code or the package.
Is there a way to reproduce the results from sklearn?

Dominant language
Julia
Stars
387
Forks
83
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from JuliaStats/MultivariateStats.jl

All issues in JuliaStats/MultivariateStats.jl

Similar issues

More Julia issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.