GithubHelp home page GithubHelp logo

Comments (6)

kunwuz avatar kunwuz commented on May 27, 2024 1

Hi, we have updated our code (#58). We believe it's related to the original data, which might not satisfy the assumption of the singularity of its covariance matrix, so we throw an exception in that case. Please let us know if you think there are other reasons. Many thanks!

from causal-learn.

kunwuz avatar kunwuz commented on May 27, 2024

Thanks for letting us know. We will look into this. Meanwhile, if possible, could you please share a minimal code and sample dataset that could reproduce that issue?

from causal-learn.

delacylab avatar delacylab commented on May 27, 2024

I get this error too, I stuck in some debug lines in the fisherz function and here are the variable values right before the crash:
var
[80, 8, 81, 82]

sub_corr_matrix
[[ 1. 0.05900512 -0.53968299 -0.77947494]
[ 0.05900512 1. -0.04393224 -0.0369982 ]
[-0.53968299 -0.04393224 1. -0.10670507]
[-0.77947494 -0.0369982 -0.10670507 1. ]]

sub_corr_matrix determinant -1.356916280487041e-15

inverse of sub_corr_matrix
[[-7.25887259e+14 -2.94842405e-01 -4.57331063e+14 -6.14610472e+14]
[-3.00253318e-01 1.00370143e+00 -1.40868234e-01 -2.12238508e-01]
[-4.57331063e+14 -1.37148843e-01 -2.88132487e+14 -3.87223301e+14]
[-6.14610472e+14 -2.07321594e-01 -3.87223301e+14 -5.20392152e+14]]

The problem appears to be that elements in the inverse matrix are going to negative infinity. Why that is, I have no idea.

from causal-learn.

jdramsey avatar jdramsey commented on May 27, 2024

Sorry to intrude, but is it possible the matrix is not singular so when you invert it you don't get a proper inverse? Have you tried multiplying the inverse by the matrix to see if you get I?

from causal-learn.

delacylab avatar delacylab commented on May 27, 2024

I multiplied the matrix and inverse matrix together like you suggested and did not get I or anything close. I checked the determinant of the matrix and it is basically 0. I researched this problem and numpy many times does not catch "basically 0" due to floating point math oddities so something is never 0 but will instead be e.g. 2.8e-14. They added an isclose function but I don't know enough about the math involved in causal-learn to guess what a good epsilon value would be to separate matrixes with legitimately very small determinants from matrixes whose determinant really is 0.

from causal-learn.

tofuwen avatar tofuwen commented on May 27, 2024

Hi @delacylab,

Thanks for researching, and finding the root cause.

Do you mind adding an assertion in our codebase to ensure the matrix is not singular before calling inverse?

In this way, we can throw a better error message to users so they know it's data issue, instead of the current confusing error message.

Of course, if you don't have time, please let us know! And we will find someone to implement this.

from causal-learn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.