cdt15 / lingam

Python package for causal discovery based on LiNGAM.
https://sites.google.com/view/sshimizu06/lingam
MIT License
372 stars 56 forks source link

LiM runs into an exception when using the option only_global=False #118

Open phyk opened 9 months ago

phyk commented 9 months ago

When using the LiM implementation, I run it on larger datasets and everything works, as long as I don't use the option only_global=False. Whenever it is set, I get the following message: ValueError: Unknown label type: continuous. Maybe you are trying to fit a classifier, which expects discrete classes on a regression target with continuous values. In case of running it on with only_global=True, everything works. I checked my data and from what I can see, I correctly define the discrete_indicator to contain all discrete features.

Can you help me out here?

YanaZeng commented 9 months ago

It looks like the error was from the local search procedure, especially from the calculation from the "_loss" function or the "_bic_scoring" function. Maybe you could debug the code to see if there is anything strange.

Thanks for your interest! If any problems, please let us know.

phyk commented 9 months ago

I found the error on my end, i miscalculated the discrete_indicator array (indicating continuous instead of binary columns).

When investigating the issue another question arose: is the discrete_indicator field ignored in case the parameter only_global is set to True?

YanaZeng commented 9 months ago

In the case where the parameter only_global is set to True, the discrete_indicator field is used as well. It is used to compute the objective function. If you miscalculated the discrete_indicator array, the code can work but might not work well, I think.