Getting Error by using interactive learning

when i run interactive learning i get this error , can anyone explain it to me ?: Exception: BinarySingleStateFeaturizer was not prepared before encoding

Can you provide a full traceback?

Hey,

I’m having the same issue

Traceback (most recent call last):
  File "/Users/wassim/Desktop/Com/TQA/AlfaChatbot/alfachatbot/alfachatbot/runners/core_runner/core_runner.py", line 37, in <module>
    CoreRunner.run()
  File "/Users/wassim/Desktop/Com/TQA/AlfaChatbot/alfachatbot/alfachatbot/runners/core_runner/core_runner.py", line 32, in run
    x = asyncio.run(agent.handle_text(input_message))
  File "/Users/wassim/anaconda/anaconda3/envs/alfa-chatbot/lib/python3.7/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "uvloop/loop.pyx", line 1451, in uvloop.loop.Loop.run_until_complete
  File "/Users/wassim/anaconda/anaconda3/envs/alfa-chatbot/lib/python3.7/site-packages/rasa/core/agent.py", line 524, in handle_text
    return await self.handle_message(msg, message_preprocessor)
  File "/Users/wassim/anaconda/anaconda3/envs/alfa-chatbot/lib/python3.7/site-packages/rasa/core/agent.py", line 446, in handle_message
    return await processor.handle_message(message)
  File "/Users/wassim/anaconda/anaconda3/envs/alfa-chatbot/lib/python3.7/site-packages/rasa/core/processor.py", line 74, in handle_message
    await self._predict_and_execute_next_action(message, tracker)
  File "/Users/wassim/anaconda/anaconda3/envs/alfa-chatbot/lib/python3.7/site-packages/rasa/core/processor.py", line 336, in _predict_and_execute_next_action
    action, policy, confidence = self.predict_next_action(tracker)
  File "/Users/wassim/anaconda/anaconda3/envs/alfa-chatbot/lib/python3.7/site-packages/rasa/core/processor.py", line 164, in predict_next_action
    probabilities, policy = self._get_next_action_probabilities(tracker)
  File "/Users/wassim/anaconda/anaconda3/envs/alfa-chatbot/lib/python3.7/site-packages/rasa/core/processor.py", line 549, in _get_next_action_probabilities
    tracker, self.domain
  File "/Users/wassim/anaconda/anaconda3/envs/alfa-chatbot/lib/python3.7/site-packages/rasa/core/policies/ensemble.py", line 343, in probabilities_using_best_policy
    probabilities = p.predict_action_probabilities(tracker, domain)
  File "/Users/wassim/anaconda/anaconda3/envs/alfa-chatbot/lib/python3.7/site-packages/rasa/core/policies/keras_policy.py", line 252, in predict_action_probabilities
    X = self.featurizer.create_X([tracker], domain)
  File "/Users/wassim/anaconda/anaconda3/envs/alfa-chatbot/lib/python3.7/site-packages/rasa/core/featurizers.py", line 408, in create_X
    X, _ = self._featurize_states(trackers_as_states)
  File "/Users/wassim/anaconda/anaconda3/envs/alfa-chatbot/lib/python3.7/site-packages/rasa/core/featurizers.py", line 335, in _featurize_states
    self.state_featurizer.encode(state) for state in tracker_states
  File "/Users/wassim/anaconda/anaconda3/envs/alfa-chatbot/lib/python3.7/site-packages/rasa/core/featurizers.py", line 335, in <listcomp>
    self.state_featurizer.encode(state) for state in tracker_states
  File "/Users/wassim/anaconda/anaconda3/envs/alfa-chatbot/lib/python3.7/site-packages/rasa/core/featurizers.py", line 102, in encode
    "BinarySingleStateFeaturizer was not prepared before encoding."
Exception: BinarySingleStateFeaturizer was not prepared before encoding.

This is where the exception is being thrown

    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

NLU Config : pipeline: "supervised_embeddings"

Policies

policies:
  - name: KerasPolicy
    epochs: 100
    max_history: 5
  - name: FallbackPolicy
    fallback_action_name: 'action_default_fallback'
  - name: MemoizationPolicy
    max_history: 5

Thanks for the traceback @wassimseif. What version of core is this on?

I was using 1.0.0rc6

Hm @wassimseif seems like you are using your own runner to run the code. Do you still run into the same problem using the CLI to train and run the bot?

This is fixed. It was just a bug in the nlu training so the core runners are not working.

About the custom runner, for production use, should i use the cli or custom runner to deploy the chatbot ?

I think that’s up to you :slight_smile: I only asked about the CLI because I wanted to know if it was your code or ours that was throwing the error.