Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Gaussian-Copula Mutual Information #677

Closed
wants to merge 3 commits into from
Closed

Conversation

DominiqueMakowski
Copy link
Member

  • Try re-implementing GCMI for signal processing.

There is an open-source Python implementation in https://github.com/robince/gcmi, but it gives unexpected results, below is a comparison of GCMI ("MI6") vs. other methods. It doesn't follow the same pattern at all...

import numpy as np
import pandas as pd

x = np.random.normal(size=400)
y = x**2

data = pd.DataFrame()
for level in np.linspace(0.01, 3, 200):
    noise = np.random.normal(scale=level, size=400)
    rez = pd.DataFrame({"Noise": [level]})
    rez["MI1"] = nk.mutual_information(x, y + noise, method="varoquaux", sigma=1)
    rez["MI2"] = nk.mutual_information(x, y + noise, method="varoquaux", sigma=0)
    rez["MI3"] = nk.mutual_information(x, y + noise, method="nolitsa")
    rez["MI4"] = nk.mutual_information(x, y + noise, method="knn")
    rez["MI5"] = nk.mutual_information(x, y + noise, method="max")
    rez["MI6"] = nk.mutual_information(x, y + noise, method="gc")
    data = pd.concat([data, rez], axis=0)

# Rescale on the same range for visualization purposes
data["MI1"] = nk.rescale(data["MI1"])
data["MI2"] = nk.rescale(data["MI2"])
data["MI3"] = nk.rescale(data["MI3"])
data["MI4"] = nk.rescale(data["MI4"])
data["MI5"] = nk.rescale(data["MI5"])
data["MI6"] = nk.rescale(data["MI6"])

data.plot(x="Noise", y=["MI1", "MI2", "MI3", "MI4", "MI5", "MI6"], kind="line")

image

@codecov-commenter
Copy link

codecov-commenter commented Jul 14, 2022

Codecov Report

Merging #677 (6e254ba) into dev (9e7775c) will decrease coverage by 0.15%.
The diff coverage is 5.88%.

@@            Coverage Diff             @@
##              dev     #677      +/-   ##
==========================================
- Coverage   52.95%   52.79%   -0.16%     
==========================================
  Files         271      271              
  Lines       12249    12282      +33     
==========================================
- Hits         6486     6484       -2     
- Misses       5763     5798      +35     
Impacted Files Coverage Δ
neurokit2/complexity/information_mutual.py 12.84% <5.88%> (-3.16%) ⬇️
neurokit2/rsp/rsp_simulate.py 93.75% <0.00%> (-4.47%) ⬇️
neurokit2/signal/signal_fixpeaks.py 73.50% <0.00%> (+0.64%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9e7775c...6e254ba. Read the comment docs.

@robince
Copy link

robince commented Jul 14, 2022

I think your signal is y=x**2 + noise. GCMI won't detect this sort of symmetric effect, it can detect only monotonic effects (it is like a rank correlation). You could try adding in abs(x) as a second dimension of x.

Also I apprecaite your interest but GCMI is licensed under the GPL so code can't be reused and released under MIT.

@DominiqueMakowski
Copy link
Member Author

Thanks a lot for your input @robince!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants