rasa/core/featurizers.py
def encode(self, state: Dict[Text, float]) -> np.ndarray:
        """Returns a binary vector indicating which features are active.

            Given a dictionary of states (e.g. 'intent_greet',
            'prev_action_listen',...) return a binary vector indicating which
            features of `self.input_features` are in the bag. NB it's a
            regular double precision float array type.

            For example with two active features out of five possible features
            this would return a vector like `[0 0 1 0 1]`

            If intent features are given with a probability, for example
            with two active features and two uncertain intents out
            of five possible features this would return a vector
            like `[0.3, 0.7, 1.0, 0, 1.0]`.

            If this is just a padding vector we set all values to `-1`.
            padding vectors are specified by a `None` or `[None]`
            value for states.
        """

        if not self.num_features:
            raise Exception("BinarySingleStateFeaturizer "
                            "was not prepared "
                            "before encoding.")

        if state is None or None in state:
            return np.ones(self.num_features, dtype=np.int32) * -1

        # we are going to use floats and convert to int later if possible
        used_features = np.zeros(self.num_features, dtype=np.float)
        using_only_ints = True
        for state_name, prob in state.items():
            if state_name in self.input_state_map:
                idx = self.input_state_map[state_name]
                used_features[idx] = prob
                using_only_ints = using_only_ints and utils.is_int(prob)
            else:
                logger.debug(
                    "Feature '{}' (value: '{}') could not be found in "
                    "feature map. Make sure you added all intents and "
                    "entities to the domain".format(state_name, prob))

        if using_only_ints:
            # this is an optimization - saves us a bit of memory
            return used_features.astype(np.int32)
        else:
            return used_features
Returns a binary vector indicating which features are active.

            Given a dictionary of states (e.g. 'intent_greet',
            'prev_action_listen',...) return a binary vector indicating which
            features of `self.input_features` are in the bag. NB it's a
            regular double precision float array type.

            For example with two active features out of five possible features
            this would return a vector like `[0 0 1 0 1]`

            If intent features are given with a probability, for example
            with two active features and two uncertain intents out
            of five possible features this would return a vector
            like `[0.3, 0.7, 1.0, 0, 1.0]`.

            If this is just a padding vector we set all values to `-1`.
            padding vectors are specified by a `None` or `[None]`
            value for states.
        
Returns a binary vector indicating which features are active.
Given a dictionary of states  return a binary vector indicating which
features of `self.input_features` are in the bag. NB it's a
regular double precision float array type.

For example with two active features out of five possible features
this would return a vector like `[0 0 1 0 1]`

If intent features are given with a probability, for example
with two active features and two uncertain intents out
of five possible features this would return a vector
like `[0.3, 0.7, 1.0, 0, 1.0]`.

If this is just a padding vector we set all values to `-1`.
padding vectors are specified by a `None` or `[None]`
value for states.
Returns a binary vector indicating which features are active . Given a dictionary of states return a binary vector indicating which features of ` self . input_features ` are in the bag . NB it ' s a regular double precision float array type . For example with two active features out of five possible features this would return a vector like ` [ 0 0 1 0 1 ] ` If intent features are given with a probability for example with two active features and two uncertain intents out of five possible features this would return a vector like ` [ 0 . 3 0 . 7 1 . 0 0 1 . 0 ] ` . If this is just a padding vector we set all values to ` - 1 ` . padding vectors are specified by a ` None ` or ` [ None ] ` value for states .
def encode(self, state: Dict[Text, float]) -> np.ndarray:
        if not self.num_features:
            raise Exception("BinarySingleStateFeaturizer "
                            "was not prepared "
                            "before encoding.")
        if state is None or None in state:
            return np.ones(self.num_features, dtype=np.int32) * -1
        used_features = np.zeros(self.num_features, dtype=np.float)
        using_only_ints = True
        for state_name, prob in state.items():
            if state_name in self.input_state_map:
                idx = self.input_state_map[state_name]
                used_features[idx] = prob
                using_only_ints = using_only_ints and utils.is_int(prob)
            else:
                logger.debug(
                    "Feature '{}' (value: '{}') could not be found in "
                    "feature map. Make sure you added all intents and "
                    "entities to the domain".format(state_name, prob))
        if using_only_ints:
            return used_features.astype(np.int32)
        else:
            return used_features
def encode ( self , state : Dict [ Text , float ] ) -> np . ndarray : if not self . num_features : raise Exception ( "BinarySingleStateFeaturizer " "was not prepared " "before encoding." ) if state is None or None in state : return np . ones ( self . num_features , dtype = np . int32 ) * - 1 used_features = np . zeros ( self . num_features , dtype = np . float ) using_only_ints = True for state_name , prob in state . items ( ) : if state_name in self . input_state_map : idx = self . input_state_map [ state_name ] used_features [ idx ] = prob using_only_ints = using_only_ints and utils . is_int ( prob ) else : logger . debug ( "Feature '{}' (value: '{}') could not be found in " "feature map. Make sure you added all intents and " "entities to the domain" . format ( state_name , prob ) ) if using_only_ints : return used_features . astype ( np . int32 ) else : return used_features
Returns a binary vector indicating which features are active.
Returns a binary vector indicating which features are active .
"""Returns a binary vector indicating which features are active.

            Given a dictionary of states (e.g. 'intent_greet',
            'prev_action_listen',...) return a binary vector indicating which
            features of `self.input_features` are in the bag. NB it's a
            regular double precision float array type.

            For example with two active features out of five possible features
            this would return a vector like `[0 0 1 0 1]`

            If intent features are given with a probability, for example
            with two active features and two uncertain intents out
            of five possible features this would return a vector
            like `[0.3, 0.7, 1.0, 0, 1.0]`.

            If this is just a padding vector we set all values to `-1`.
            padding vectors are specified by a `None` or `[None]`
            value for states.
        """ # we are going to use floats and convert to int later if possible # this is an optimization - saves us a bit of memory
self
state
Dict[Text, float]