# Help needed to get started with text classification

**URL:** https://support.prodi.gy/t/help-needed-to-get-started-with-text-classification/559
**Category:** Uncategorized
**Tags:** usage, textcat
**Created:** [May 22, 2018, 7:55pm UTC](https://support.prodi.gy/t/help-needed-to-get-started-with-text-classification/559 "2018-05-22T19:55:52Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)
#### Post date: [May 23, 2018, 7:08pm UTC](https://support.prodi.gy/t/help-needed-to-get-started-with-text-classification/559/2 "2018-05-23T19:08:49Z")

</div>

Yay, that's nice to hear! Your workflow looks really good so far, so definitely keep us updated about the results. Answers below:

> [@vanatteveldt](#):
>
> Question 1: Does this sound like the right way to use prodigy?

Yes, that sound like a good plan. How well this will work obviously depends on that data you have etc. etc., but being able to pre-train a model is always nice, since you won't have to deal with the cold start problem.

> [@vanatteveldt](#):
>
> Question 2: We tried doing steps 1 and 2, but the performance is immediately ~100%. It seems like the model tries to predict accept/reject rather than our issue categoires.

Yes, the problem in your case is that you don't have any negative examples – and Prodigy is optimised to train from binary data and sparse annotations. So the model here simply learned that "every label is correct", which is true – but obviously not generalisable.

One solution would be to add negative examples, e.g. by swapping out the labels. But you'll probably find it more efficient to just use spaCy directly – [here's a simple code example](https://spacy.io/usage/training#example-textcat). (In spaCy v2.0, all components share the same training API, so you can also take inspiration from the other examples.) Once you have a pre-trained model that predicts _something_, you can load it with `textcat.teach` and keep improving it on new data.

> [@vanatteveldt](#):
>
> Question 3: (...) Is that the correct format, given that the target label is ‘wonen’?

Yes, that's all correct. We usually write all our labels in caps, e.g. `WONEN`, but this is only a stylistic thing and doesn't actually matter.

> [@vanatteveldt](#):
>
> Question 4: We also have a dictionary of terms for each issue, and a structural topic model trained with topics that correspond (somewhat) with the target issues identified. Does it make sense to somehow input these into the initial model as well, and how would we do this?

The terms dictionary could be very useful to bootstrap more training data and select examples from very large corpora. The `textcat.teach` recipe supports a `--patterns` argument that can point to a JSONL file of patterns that look like this:

```json
{"label": "GERMANY", "pattern": [{"lower": "berlin"}]}
{"label": "USA", "pattern": "New York"}

```

The patterns can either be a list of dictionaries, with one dictionary describing a token and its attributes (just like the patterns for spaCy's [rule-based `Matcher`](http://spacy.io/usage/linguistic-features#rule-based-matching)), or exact strings. Using the patterns, you can give examples of words that are likely indicators of a category (e.g. texts including "berlin" are likely about Germany). You may come across false positives, too – but this is good, because you also want your model to learn about those cases.

> [@vanatteveldt](#):
>
> Question 5: Do we need to specify the spacy model (“nl”?) and/or indicate what we think are good features?

If you're working with Dutch text, you probably want to start off with the small Dutch model, [`nl_core_news_sm`](https://spacy.io/models/nl). If you don't care about the other components (tagger, parser, NER) and only want to train the text classifier, you can also just save out a "blank" model instead:

```python
import spacy
nlp = spacy.blank('nl')

```

Prodigy's annotation recipes can take the name of a model package or a path to a model directory – so you can simply pass in the directory containing the pre-trained model that you saved out.

---

_[View the full topic](https://support.prodi.gy/t/help-needed-to-get-started-with-text-classification/559)._
