def _in_training_data_fraction(action_list): """Given a list of action items, returns the fraction of actions that were predicted using one of the Memoization policies.""" from rasa.core.policies import SimplePolicyEnsemble in_training_data = [ a["action"] for a in action_list if not SimplePolicyEnsemble.is_not_memo_policy(a["policy"]) ] return len(in_training_data) / len(action_list)
def is_predicted_event_in_training_data(policy: Optional[Text]): """Determine whether event predicted by `policy` was in the training data. A predicted event is considered to be in training data if it was predicted by the `MemoizationPolicy` or the `AugmentedMemoizationPolicy`. Args: policy: Policy of the predicted event. Returns: `True` if the event was not predicted, otherwise `True` if it was not predicted by a memo policy, else `False`. """ if not policy: # event was not predicted by a policy return True return not SimplePolicyEnsemble.is_not_memo_policy(policy)