coopihc.inference.GoalInferenceWithUserPolicyGiven.GoalInferenceWithUserPolicyGiven
- class GoalInferenceWithUserPolicyGiven(*args, user_policy_model=None, **kwargs)[source]
- Bases: - coopihc.inference.BaseInferenceEngine.BaseInferenceEngine- An Inference Engine used by an assistant to infer the ‘goal’ of a user via Bayesian updating. The likelihood is given through an - ELLDiscretePolicy, which acts as the model of the user behavior.- Expectations of the engine - This inference engine expects: - the agent to have a ‘belief’ state, corresponding to the discrete belief pmf. in its internal state: 
- the modeler to attach a user policy model to the engine - inference_engine._attach_policy(user_policy_model)
- the modeler to attach the set of possible user goals - inference_engine.attach_set_theta(set_theta)
 
- Inference - Bayesian updating in the discrete case. Computes for each target :math:` heta` the associated posterior probability, given an observation \(x\) and the last user action \(y\): \[P(\Theta = \theta | X=x, Y=y) = \frac{p(Y = y | \Theta = \theta, X=x)}{\sum_{\Theta} p(Y=y|\Theta = \theta, X=x)} P(\Theta = \theta).\]- The likelihood model (directly obtainable from an - ELLDiscretePolicy) \(p(Y = y | \Theta = \theta, X=x)\) has to be supplied- # Define the likelihood model for the user policy # user_policy_model = XXX # assert isinstance(user_policy_model, ELLDiscretePolicy) inference_engine = GoalInferenceWithUserPolicyGiven() # Attach it to the engine inference_engine._attach_policy(user_policy_model) - It also expects that the set of :math:` heta`’s is supplied: - set_theta = [ { ("user_state", "goal"): StateElement( t, discrete_space(numpy.array(<XXX>), ) } for t in <potential_targets> ] inference_engine.attach_set_theta(set_theta) 
- Render - —- plot mode: - This engine will plot a bar chart of the beliefs on the assistant axis - —- text mode: - This engine will print out the beliefs to the terminal 
- Example files - coopihczoo.pointing.assistants 
 - Parameters
- user_policy_model ( - EELDiscretePolicy, optional) – a model of the user policy, defaults to None
 - Methods - add observation - attach_set_theta- Bind function to the engine with a given name. - Apply this decorator to use self.agent_observation as default value to infer from if agent_observation = None - infer- render- reset _summary_ - Attributes - The agent's last action - host- The last observation. - role- The current agent state - unwrapped- add_observation(observation)
- add observation - Add an observation to a buffer. If the buffer does not exist, create a naive buffer. The buffer has a size given by buffer length - Parameters
- observation ( - State) – observation produced by an engine
 
 - bind(func, as_name=None)
- Bind function to the engine with a given name. If as_name is None, then the func name is used. - Parameters
- func (function) – function to bind 
- as_name (string, optional) – name of resulting method, defaults to None 
 
- Returns
- bound method 
- Return type
- method 
 
 - default_value()
- Apply this decorator to use self.agent_observation as default value to infer from if agent_observation = None 
 - reset(random=True)
- reset _summary_ - Empty the buffer - Parameters
- random (bool, optional) – whether to randomize parameters internal to the inference engine. This is provided in case of subclass the BaseInferenceEngine, defaults to True.