How to do manipulation of a variable in the network

The engine.
Post Reply
BayesFusionUser123
Posts: 15
Joined: Tue Jun 10, 2025 3:51 pm

How to do manipulation of a variable in the network

Post by BayesFusionUser123 »

We want to use SMILE to do manipulation for a variable, and see how the manipulation can affect the target variable.

Here is a brief explanation of the difference between "observing" and "manipulation/intervening".

Given a graph B -> A, A -> T, B -> T.

In Tutorial 2, if we use function `change_evidence_and_update(net, 'A', 'A___1')` , it is doing observing, since the posteriors of B changes.

For doing "manipulation" of A by setting `A` as value `A___1`, the posteriors of B should not change.

## idea

To do "manipulation" of A, we come up with an idea that, we can remove the arch B -> A (in general cases, we should remove all incoming edges of A), then set `A` as value `A___1`, then we can check how the parameter of `T` (our target) change.

So, our steps:
1. pre-define a network B -> A, A -> T, B -> T and construct it.
2. learn parameter using EM from a dataset for this network.
3. Remove the arch B -> A
4. setting A to A___1
5. check the parameter of T.

To better illustrate "observing vs manipulation", I include a python code here named: `observing_vs_manipulation_discrete.py`

My question:

I also include my code in ipython notebook using SMILE to do manipulation. Could you please check if I am doing it right?

Is this way of doing "manipulation" of A right? Or SMILE has other more convenient way of doing it?

Thanks you very much.
Attachments
forum_question_for_variable_manipulation.zip
(6.93 KiB) Downloaded 7 times
shooltz[BayesFusion]
Site Admin
Posts: 1468
Joined: Mon Nov 26, 2007 5:51 pm

Re: How to do manipulation of a variable in the network

Post by shooltz[BayesFusion] »

Consider using Network.set_controlled_value. For more info on arc cutting/value control, please refer to GeNIe manual, chapter "Controlling values". In the PDF version of the manual, the chapter number is 6.2.8.
BayesFusionUser123
Posts: 15
Joined: Tue Jun 10, 2025 3:51 pm

Re: How to do manipulation of a variable in the network

Post by BayesFusionUser123 »

Thanks, I have read "GeNIe manual, chapter 'Controlling values'". it is clear to me now.

Can I ask a further question?
I search both GeNIe manual and Wrapper manual.
I did not find the document to introduce how to use the function `Network.set_controlled_value`.

Could you please instruct me where I can find a document for this function? Thanks.
Post Reply