# Custom objective for textcat

**URL:** <https://support.prodi.gy/t/custom-objective-for-textcat/2005>\
**Category:** Uncategorized\
**Tags:** usage, textcat\
**Created:** [September 11, 2019, 11:53pm UTC](https://support.prodi.gy/t/custom-objective-for-textcat/2005 "2019-09-11T23:53:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![timothyjlaurent](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/timothyjlaurent/32/590_2.png) [@timothyjlaurent](https://support.prodi.gy/u/timothyjlaurent)\
**Post date:** [September 11, 2019, 11:53pm UTC](https://support.prodi.gy/t/custom-objective-for-textcat/2005/1 "2019-09-11T23:53:25Z")

</div>

So I'm writing a custom textcat batch train recipe that will persist the model to a cloud data source.

To accomplish this, I copied the textcat.batch\_train recipe in the repo and added some calls to our persistence client.

While doing this, I noticed that batch\_train uses the model with the highest accuracy as the 'best' model. My dataset is very sparse with passages that should be labeled. Therefor a model could just always predict negative for the label if trying to maximize accuracy -- I've changed my recipe to use fscore instead of accuracy -- are there any downsides to this approach?

Maybe such an option could be included on the batchtrain recipes?

---

<div class="post-metadata">

**Author:** ![honnibal](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/honnibal/32/35_2.png) [@honnibal](https://support.prodi.gy/u/honnibal)\
**Post date:** [September 19, 2019, 10:38pm UTC](https://support.prodi.gy/t/custom-objective-for-textcat/2005/2 "2019-09-19T22:38:25Z")

</div>

Sorry for the delay getting to this --- I missed the thread before somehow.

You're right that the default metric might not be the best choice for all situations. v2.2 of spaCy actually has some improvements in the textcat evaluation that I hope we'll be able to take advantage of in Prodigy.

In the meantime, I think implementing a custom recipe to choose the model under whatever criterion you need should be a good solution.
