title: train spacy for text classification
body: <p>After reading the <a href="https://spacy.io/usage/training#textcat" rel="noreferrer">docs</a> and doing the <a href="https://course.spacy.io/chapter4" rel="noreferrer">tutorial</a> I figured I'd make a small demo. Turns out my model does not want to train. Here's the code</p>
  
  <pre><code>import spacy
  import random
  import json
  
  TRAINING_DATA = [
      ["My little kitty is so special", {"KAT": True}],
      ["Dude, Totally, Yeah, Video Games", {"KAT": False}],
      ["Should I pay $1,000 for the iPhone X?", {"KAT": False}],
      ["The iPhone 8 reviews are here", {"KAT": False}],
      ["Noa is a great cat name.", {"KAT": True}],
      ["We got a new kitten!", {"KAT": True}]
  ]
  
  nlp = spacy.blank("en")
  category = nlp.create_pipe("textcat")
  nlp.add_pipe(category)
  category.add_label("KAT")
  
  # Start the training
  nlp.begin_training()
  
  # Loop for 10 iterations
  for itn in range(100):
      # Shuffle the training data
      random.shuffle(TRAINING_DATA)
      losses = {}
  
      # Batch the examples and iterate over them
      for batch in spacy.util.minibatch(TRAINING_DATA, size=2):
          texts = [text for text, entities in batch]
          annotations = [{"textcat": [entities]} for text, entities in batch]
          nlp.update(texts, annotations, losses=losses)
      if itn % 20 == 0:
          print(losses)
  </code></pre>
  
  <p>When I run this the output suggests that very little is learned.</p>
  
  <pre><code>{'textcat': 0.0}
  {'textcat': 0.0}
  {'textcat': 0.0}
  {'textcat': 0.0}
  {'textcat': 0.0}
  </code></pre>
  
  <p>This feels <em>wrong</em>. There should be an error or a meaningful tag. The predictions confirm this. </p>
  
  <pre class="lang-py prettyprint-override"><code>for text, d in TRAINING_DATA:
      print(text, nlp(text).cats)
  
  # Dude, Totally, Yeah, Video Games {'KAT': 0.45303162932395935}
  # The iPhone 8 reviews are here {'KAT': 0.45303162932395935}
  # Noa is a great cat name. {'KAT': 0.45303162932395935}
  # Should I pay $1,000 for the iPhone X? {'KAT': 0.45303162932395935}
  # We got a new kitten! {'KAT': 0.45303162932395935}
  # My little kitty is so special {'KAT': 0.45303162932395935}
  </code></pre>
  
  <p>It feels like my code is missing something but I can't figure out what. </p>