VariableElimination NaN values #1533
-
Hello! I have built a BayesianNetwork model using pgmpy library. It all works well if my evaluation dataset does not contain any NaN values. If I have any NaN in any parameter of the model, it gives an error of
The evaluation technique that I use (code snippet):
Does anyone know how can I make VariableElimination work including NaN values? I tried to google some solutions but I didn't find any information about handling missing values with VariableElimination. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
@jonasvit Does NaN represent missing values in your dataset? If that is the case, you can just leave it out from the evidence argument and the algorithm will marginalize (i.e. treat it to be possible in any state with probability depending on the training dataset) the missing variable automatically. |
Beta Was this translation helpful? Give feedback.
-
@jonasvit Since you will have to do a |
Beta Was this translation helpful? Give feedback.
@jonasvit Since you will have to do a
query
call for each row of your dataset (as the evidence argument only accepts single state names),you can write a simple check before the call which modifies the evidence argument according to the observed values.