clearEvidence without removing other nodes probabilities

The engine.
Post Reply
alicegiamp
Posts: 2
Joined: Tue Aug 29, 2023 12:28 pm

clearEvidence without removing other nodes probabilities

Post by alicegiamp »

I am trying to find a way to update the network giving the true value of a node, and then deleting only that value but still having the updated probabilities of the other nodes, also the ones that depend on that node. I am using rSMILE:

Code: Select all

# Save the obtain probabilities for the signals:
    signals <- net$getNodeValue("Signal")
    
# Save the mean:
    mean_sig <- sum(signals*states)
    mean_state <- sum(statesss*signal_norm)
    
    # Set the evidence at the real stimulus value 
    # (that is set 0 for construction of the angles):
    net$setContEvidence("Signal", 0)
    
    # Update the network:
    net$updateBeliefs()
    
    # Clear the evidence of the real signal:
    net$clearEvidence("Signal")
In the last row, I aim to remove the evidence of the actual stimulus while preserving the probabilities of all the parent nodes of the "Signal" node. How can I achieve this without affecting the probabilities of the parent nodes?

I want to retain and update the posterior probabilities of the nodes after each trial, allowing them to learn in the absence of the actual signal (net$setContEvidence("Signal", 0)). Then, in the subsequent trial, I intend to start with the updated probabilities, but with the signal status unknown.

I've attempted to store the probabilities of the nodes before clearing the evidence of the signal. However, I'm encountering difficulties in correctly resetting the probabilities to their previous values in the subsequent trial.

Code: Select all

# Save the probs of the nodes that are deleted by the following clearEvidence:
    prob <- net$getNodeValue("Difficulty")
    
    # Clear the evidence of the real signal:
    net$clearEvidence("Signal")
    
    net$setVirtualEvidence("Difficulty", prob)
Can you give me some int to solve my problem?

UPDATE

I solved it by saving the probabilities before clearing the evidence and re-define the nodes with the previously updated probabilities.
I was wondering if there is a clever way to do it.
shooltz[BayesFusion]
Site Admin
Posts: 1424
Joined: Mon Nov 26, 2007 5:51 pm

Re: clearEvidence without removing other nodes probabilities

Post by shooltz[BayesFusion] »

Can you post your model here? Alternatively, send me a private forum message with a network attached or a download link.
marek [BayesFusion]
Site Admin
Posts: 435
Joined: Tue Dec 11, 2007 4:24 pm

Re: clearEvidence without removing other nodes probabilities

Post by marek [BayesFusion] »

I have read your post but have frankly difficulties in understanding what precisely you want to do from the theoretical perspective. What I understand, perhaps wrongly, is that you would like to observe a node, calculate the impact of that observation, but then clear the observation but preserve its impact on the other nodes. It does not seem to me that this is theoretically possible (assuming that I understand your intentions correctly). Updating beliefs calculates the conditional probability distribution over the nodes in the network given the condition (your evidence). If that condition/evidence is gone, the conditional probability distribution is gone (in the sense of not being valid) as well. There are two directions of work that I can think of here: (1) modifying your model based on what the evidence has told you; in this case, you need to modify the CPTs or equations in such a way that they consider the (hypothetical) evidence; this is not an easy/obvious task, and (2) dynamic networks, in which you model the state of the world over time; at time t1 you make an observation and that has impact on all the nodes at time t1; it will also have impact on the nodes at time t2 while the node that you observed is in the past; at time t2 the same node is unobserved. Does this all make sense? Have I understood you?
Cheers,

Marek
alicegiamp
Posts: 2
Joined: Tue Aug 29, 2023 12:28 pm

Re: clearEvidence without removing other nodes probabilities

Post by alicegiamp »

You got it right.
I solved the problem by saving the probabilities before clearing the evidence and re-define the nodes with the previously updated probabilities.

In this way, I was able to use a not dynamic network and at the same time I decided which CPTs maintain or reset to original prior/default values.
Post Reply