title: Making chatbot say "I dont know" when its not sure about the answer
body: <p><strong>Description</strong></p>
  <p>Hello, I am following this tutorial on chatbot with neural net. I would need help with reviewing a response code of &quot;I dont know&quot; response, when the bot is not sure about the answer. Its trained on json file called intents, which contains tags (each tag each conversation topic) like greeting, goodbye, items for sale, etc. Each tag contains questions customers can ask and responses the bot provides.</p>
  <p>This is part of the code for the bot and responses (I hope its enough, otherwise i can upload entire code):</p>
  <pre><code>def predict_class(sentence, model):
      p = bow(sentence, words,show_details=False)
      res = model.predict(np.array([p]))[0]
      ERROR_THRESHOLD = 0.6
      results = [[i,r] for i,r in enumerate(res) if r&gt;ERROR_THRESHOLD]
     #sort by strength of probability
      results.sort(key=lambda x: x[1], reverse=True)
      return_list = []
      for r in results:
          return_list.append({&quot;intent&quot;: classes[r[0]], &quot;probability&quot;: str(r[1])})
      return return_list
  def getResponse(ints, intents_json):
      if not ints: 
        tag = &quot;noanswer&quot;
      else:
          tag = ints[0]['intent']
      list_of_intents = intents_json['intents']
      for i in list_of_intents:
          if(i['tag']== tag):
              result = random.choice(i['responses'])
              break
      return result
  </code></pre>
  <p>In predict_class there is the ErrorThreshold set for 60%, anything below will not be used. Then in getResponse function I just put the code if not ints then the tag will be &quot;noanswer&quot; - this tag gives responses like &quot;I dont understand&quot; , &quot;I dont know&quot; etc.</p>
  <p><strong>Problem</strong></p>
  <p>The problem is, that it can filter out totally random questions like &quot;Who is Elon Musk?&quot; the response would be &quot;I dont know&quot;, but if I type some gibberish like &quot;fjlsbnljf&quot; or &quot;F*ck you&quot; it still gives me responses.
  Would you have some idea how to code it in different way, so that if the bot is not sure about the response, or if I type some random letters it would also return to me the &quot;noanswer&quot; tag? I may increase the threshold but then I risk that it would also discard the correct answers</p>