-
Hi all, For a simulation study I have sampled data from a SCM by first using gcm.auto.assign_causal_machanisms(causal_model, data) and also used causal_model.set_causal_mechanism(node, gcm.AdditiveNoiseModel(gcm.ml.create_linear_regressor()). For my thesis, I want to print the linear equation which is used to generate data from the causal model, but cant find how I can do that. I want to know it in the form: Node1 = 0.8*Node2 + 0.05Node3 + N(0,20) for example. Is this possible for linear equations? Is this also possible for non-linear equations? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi Stan, there is no direct way to print it, but you can access the model parameters. These, however, depend on the used models. Generally, you can access the fitted sklearn models and their parameters. For non-linear models, these might be difficult to interpret (depending on the model type). The easiest is with the linear models as you did by setting them explicitly. Note, however, that the
The example should run by itself and also with your causal model if all models are linear. |
Beta Was this translation helpful? Give feedback.
-
Hey, you could do the same thing by accessing the weights of the scikit-learn logistic regression model. However, due to the logic on top (getting class thresholds and then sampling based on uniform noise), the formula to represent this becomes more complicated. |
Beta Was this translation helpful? Give feedback.
Hi Stan,
there is no direct way to print it, but you can access the model parameters. These, however, depend on the used models. Generally, you can access the fitted sklearn models and their parameters. For non-linear models, these might be difficult to interpret (depending on the model type). The easiest is with the linear models as you did by setting them explicitly. Note, however, that the
AdditiveNoiseModel
(and auto assignment) typically uses anEmpiricalDistribution
for the noise which is parameter free. But you can also explicitly assign, e.g., a Gaussian distribution. I prepared a code snippet that prints something like your example, but it currently only works with linear models: