# Exporting dataset from prodigy and train textcat in spaCy v3

**URL:** <https://support.prodi.gy/t/exporting-dataset-from-prodigy-and-train-textcat-in-spacy-v3/4402>\
**Category:** Uncategorized\
**Tags:** spacy, done, textcat\
**Created:** [July 2, 2021, 11:31pm UTC](https://support.prodi.gy/t/exporting-dataset-from-prodigy-and-train-textcat-in-spacy-v3/4402 "2021-07-02T23:31:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![teresa](https://avatars.discourse-cdn.com/v4/letter/t/958977/32.png) [@teresa](https://support.prodi.gy/u/teresa)\
**Post date:** [July 2, 2021, 11:31pm UTC](https://support.prodi.gy/t/exporting-dataset-from-prodigy-and-train-textcat-in-spacy-v3/4402/1 "2021-07-02T23:31:22Z")

</div>

In prodigy, I used the data-to-spacy recipe to export the dataset to a .json file, using -TE. Then in spacy v3, I used the convert command to convert the json to .spacy format. No error during conversion. But when I'm training a textcat pipeline, it always gives CATS\_SCORE=100 right the way and all the time, as if it thinks all the data are labelled the same way. (exclusive\_classes is set to true in config.cfg)  
In the .json file, I can see that the format is like this:  
` "cats":[{"label":"MyLabel","value":0.0}]`  
The value is either 0.0 or 1.0.  
In cats, does it need the opposite label as well? like  
` "cats": {"POSITIVE": 1.0, "NEGATIVE": 0.0}`

---

<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:** [July 5, 2021, 12:38am UTC](https://support.prodi.gy/t/exporting-dataset-from-prodigy-and-train-textcat-in-spacy-v3/4402/2 "2021-07-05T00:38:32Z")

</div>

Hi! How many labels does your data have in total? Do you only have the one label, `MyLabel`? If your goal is to predict a single exclusive label, then you're right and you would need a second label that the model should predict instead if your main label doesn't apply.

This is definitely something we need to fix going forward in the upcoming version of Prodigy if text classification data with only one label is provided and `--textcat-exclusive` is set. (It's maybe a bit unideal, but in that case, it should probably just add a label like `OTHER` automatically and set that to `1.0` if the other label doesn't apply.)

As a workaround, one option could be to just write a quick script that adds a second label to all the `cats`, which should be pretty easy to do programmatically.

---

<div class="post-metadata">

**Author:** ![teresa](https://avatars.discourse-cdn.com/v4/letter/t/958977/32.png) [@teresa](https://support.prodi.gy/u/teresa)\
**Post date:** [July 6, 2021, 12:34pm UTC](https://support.prodi.gy/t/exporting-dataset-from-prodigy-and-train-textcat-in-spacy-v3/4402/3 "2021-07-06T12:34:42Z")

</div>

Thanks for the reply. I will give it a try.

---

<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:** [July 7, 2021, 1:17am UTC](https://support.prodi.gy/t/exporting-dataset-from-prodigy-and-train-textcat-in-spacy-v3/4402/4 "2021-07-07T01:17:00Z")

</div>

Btw, to add to my comment above, if your data only has one label, you can use the `textcat_multilabel` component instead of the regular `textcat` component: [https://spacy.io/api/textcategorizer](https://spacy.io/api/textcategorizer)

---

<div class="post-metadata">

**Author:** ![psimm](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/psimm/32/2087_2.png) [@psimm](https://support.prodi.gy/u/psimm)\
**Post date:** [July 7, 2021, 3:16pm UTC](https://support.prodi.gy/t/exporting-dataset-from-prodigy-and-train-textcat-in-spacy-v3/4402/5 "2021-07-07T15:16:48Z")

</div>

I'm not sure I understand. Did I get this right?

- `textcat` requires two labels, one for yes and one for no
- Prodigy's output only has the yes label and misses the no label
- one workaround to this is adding the No label to the output and using `textcat`
- another workaround is to use `textcat_multilabel` without changing the Prodigy output

And a follow up question: Does using `textcat_multilabel` as a workaround have any other implications on the text classification architecture and model performance?

---

<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:** [July 8, 2021, 4:11am UTC](https://support.prodi.gy/t/exporting-dataset-from-prodigy-and-train-textcat-in-spacy-v3/4402/6 "2021-07-08T04:11:09Z")

</div>

> [@psimm](#):
>
> I'm not sure I understand. Did I get this right?

Yes, that's correct. To make the first point more explicity: `textcat` requires at least two labels, so if your task is binary, that would have to be one for the binary label and one for everything else. But of course, it can also have more labels. The latest spaCy v3.1 will now also [raise explicitly](https://github.com/explosion/spaCy/pull/8584) if you initialize a `textcat` components with only one label.

> [@psimm](#):
>
> And a follow up question: Does using `textcat_multilabel` as a workaround have any other implications on the text classification architecture and model performance?

The `textcat_multilabel` component is a variation of the `textcat` component. It uses the same architectures by default and the config only really differs in the `exclusive_classes` setting. The main difference is in the initialization and scoring:

> <https://github.com/explosion/spaCy/blob/master/spacy/pipeline/textcat_multilabel.py>

The choice of components will have an impact on the results, but that's mostly due ot the `exclusive_classes` setting and how the labels are interpreted.

---

<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:** [August 12, 2021, 12:10pm UTC](https://support.prodi.gy/t/exporting-dataset-from-prodigy-and-train-textcat-in-spacy-v3/4402/7 "2021-08-12T12:10:14Z")

</div>

Just released v1.11, which now supports separate arguments for `--textcat` (mutually exclusive categories) and `--textcat-multilabel` (single label or multiple non-exclusive labels): [https://prodi.gy/docs/recipes#train](https://prodi.gy/docs/recipes#train)
