# Sentiment Analysis Pipeline on single label function\_to\_apply not working

**URL:** <https://discuss.huggingface.co/t/sentiment-analysis-pipeline-on-single-label-function-to-apply-not-working/15746>\
**Category:** 🤗Transformers\
**Created:** [March 16, 2022, 12:32am UTC](https://discuss.huggingface.co/t/sentiment-analysis-pipeline-on-single-label-function-to-apply-not-working/15746 "2022-03-16T00:32:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![seanfarrell](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@seanfarrell](https://discuss.huggingface.co/u/seanfarrell)\
**Post date:** [March 16, 2022, 12:32am UTC](https://discuss.huggingface.co/t/sentiment-analysis-pipeline-on-single-label-function-to-apply-not-working/15746/1 "2022-03-16T00:32:45Z")

</div>

Hi,

I trained a model using bertforsequenceclassification using a binary label system, I am trying to express some values from my test-set using the pipeline function as follows:

```auto
classifier = pipeline("sentiment-analysis", model=model,
tokenizer=tokenizer,function_to_apply="softmax")
result = classifier("Dog very ill.")[0]
#{'label': 'LABEL_1', 'score': 0.9970490336418152}

```

or

```auto
classifier = pipeline("sentiment-analysis", model=model,
tokenizer=tokenizer,function_to_apply="sigmoid")
result = classifier("Dog very ill.")[0]
#{'label': 'LABEL_1', 'score': 0.9585336446762085}

```

I am trying to get a sigmoid result (where labels closer to 0 will be between 0-0.50 and labels closer to 1 be 0.51-1) but regardless the outputs are the same whether I specify auto/sigmoid/softmax (Label: 0, Score: 0.00 - \> 1.00, Label: 1, Score: 0.00-\> 1.00)

Any Ideas? Many thanks in advanced

---

<div class="post-metadata">

**Author:** ![seanfarrell](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@seanfarrell](https://discuss.huggingface.co/u/seanfarrell)\
**Post date:** [March 17, 2022, 10:28am UTC](https://discuss.huggingface.co/t/sentiment-analysis-pipeline-on-single-label-function-to-apply-not-working/15746/2 "2022-03-17T10:28:34Z")

</div>

I have the solution to my problem, so stating it below just in case anyone else wanted the same thing

I would ignore the `function_to_apply` and instead use `return_all_scores =True`. So typically, it will return the highest scoring label + Label itself (e.g, `{'label': 'LABEL_1', 'score': 0.9585...}`) , however if you are wanting a sigmoid/logisitic regression style response (where all value sit on a continious scale between 0 and 1 by setting `return_all_scores =True` it will return a dictionary with `[[{'label': 'LABEL_0', 'score': 0.3905504047870636}, {'label': 'LABEL_1', 'score': 0.609449565410614}]]` where the sum of both =1

By using

```auto
result = classifier("Dog very ill.")
result[0][1].get('score')

```

Where ‘result’ is your text inside the classifier it will spit out just the score,without the other label, and just the score we want (specififying [0][1] will highlight label\_1, whereas [0][0] will do label\_2

Anyways hope this helps
