<commit_before>---
layout: model
title: Vaccine Sentiment Classifier (BioBERT)
author: <NAME>
name: bert_sequence_classifier_vaccine_sentiment
date: 2022-07-28
tags: [public_health, vaccine_sentiment, en, licensed, sequence_classification]
task: Sentiment Analysis
language: en
edition: Spark NLP for Healthcare 4.0.0
spark_version: 3.0
supported: true
article_header:
  type: cover
use_language_switcher: "Python-Scala-Java"
---

## Description

This model is a [BioBERT](https://nlp.johnsnowlabs.com/2022/07/18/biobert_pubmed_base_cased_v1.2_en_3_0.html) based sentimental analysis model that can extract information from COVID-19 Vaccine-related tweets. The model predicts whether a tweet contains positive, negative, or neutral sentiments about COVID-19 Vaccines.

## Predicted Entities

`neutral`, `positive`, `negative`

{:.btn-box}
<button class="button button-orange" disabled>Live Demo</button>
<button class="button button-orange" disabled>Open in Colab</button>
[Download](https://s3.amazonaws.com/auxdata.johnsnowlabs.com/clinical/models/bert_sequence_classifier_vaccine_sentiment_en_4.0.0_3.0_1658995472179.zip){:.button.button-orange.button-orange-trans.arr.button-icon}

## How to use



<div class="tabs-box" markdown="1">
{% include programmingLanguageSelectScalaPythonNLU.html %}
```python
document_assembler = DocumentAssembler() \
    .setInputCol("text") \
    .setOutputCol("document")

tokenizer = Tokenizer() \
    .setInputCols(["document"]) \
    .setOutputCol("token")

sequenceClassifier = MedicalBertForSequenceClassification.pretrained("bert_sequence_classifier_vaccine_sentiment", "en", "clinical/models")\
    .setInputCols(["document","token"])\
    .setOutputCol("class")

pipeline = Pipeline(stages=[
    document_assembler, 
    tokenizer,
    sequenceClassifier    
])

text_list = ['A little bright light for an otherwise dark week. Thanks researchers, and frontline workers. Onwards.', 
             'People with a history of severe allergic reaction to any component of the vaccine should not take.', 
             '43 million doses of vaccines administrated worldwide...Production capacity of CHINA to reach 4 b']

data = spark.createDataFrame(text_list, StringType()).toDF("text")
result = pipeline.fit(data).transform(data)
```
```scala
val documenter = new DocumentAssembler() 
    .setInputCol("text") 
    .setOutputCol("document")

val tokenizer = new Tokenizer()
    .setInputCols("document")
    .setOutputCol("token")

val sequenceClassifier = MedicalBertForSequenceClassification.pretrained("bert_sequence_classifier_vaccine_sentiment", "en", "clinical/models")
    .setInputCols(Array("document","token"))
    .setOutputCol("class")

val pipeline = new Pipeline().setStages(Array(documenter, tokenizer, sequenceClassifier))

val data = Seq(Array("A little bright light for an otherwise dark week. Thanks researchers, and frontline workers. Onwards.", 
                     "People with a history of severe allergic reaction to any component of the vaccine should not take.", 
                     "43 million doses of vaccines administrated worldwide...Production capacity of CHINA to reach 4 b")).toDS.toDF("text")

val result = pipeline.fit(data).transform(data)
```
</div>

## Results

```bash
+-----------------------------------------------------------------------------------------------------+----------+
|text                                                                                                 |class     |
+-----------------------------------------------------------------------------------------------------+----------+
|A little bright light for an otherwise dark week. Thanks researchers, and frontline workers. Onwards.|[positive]|
|People with a history of severe allergic reaction to any component of the vaccine should not take.   |[negative]|
|43 million doses of vaccines administrated worldwide...Production capacity of CHINA to reach 4 b     |[neutral] |
+-----------------------------------------------------------------------------------------------------+----------+
```

{:.model-param}
## Model Information

{:.table-model}
|---|---|
|Model Name:|bert_sequence_classifier_vaccine_sentiment|
|Compatibility:|Spark NLP for Healthcare 4.0.0+|
|License:|Licensed|
|Edition:|Official|
|Input Labels:|[document, token]|
|Output Labels:|[class]|
|Language:|en|
|Size:|406.5 MB|
|Case sensitive:|true|
|Max sentence length:|128|

## References

Curated from several academic and in-house datasets.

## Benchmarking

```bash
              precision    recall  f1-score   support 
     neutral       0.82      0.78      0.80      1007 
    positive       0.88      0.90      0.89      1002 
    negative       0.83      0.86      0.84       881 

    accuracy                           0.85      2890 
   macro avg       0.85      0.85      0.85      2890 
weighted avg       0.85      0.85      0.85      2890 
```<commit_msg>updated benchmark format<commit_after>---
layout: model
title: Vaccine Sentiment Classifier (BioBERT)
author: <NAME>
name: bert_sequence_classifier_vaccine_sentiment
date: 2022-07-28
tags: [public_health, vaccine_sentiment, en, licensed, sequence_classification]
task: Sentiment Analysis
language: en
edition: Spark NLP for Healthcare 4.0.0
spark_version: 3.0
supported: true
article_header:
  type: cover
use_language_switcher: "Python-Scala-Java"
---

## Description

This model is a [BioBERT](https://nlp.johnsnowlabs.com/2022/07/18/biobert_pubmed_base_cased_v1.2_en_3_0.html) based sentimental analysis model that can extract information from COVID-19 Vaccine-related tweets. The model predicts whether a tweet contains positive, negative, or neutral sentiments about COVID-19 Vaccines.

## Predicted Entities

`neutral`, `positive`, `negative`

{:.btn-box}
<button class="button button-orange" disabled>Live Demo</button>
<button class="button button-orange" disabled>Open in Colab</button>
[Download](https://s3.amazonaws.com/auxdata.johnsnowlabs.com/clinical/models/bert_sequence_classifier_vaccine_sentiment_en_4.0.0_3.0_1658995472179.zip){:.button.button-orange.button-orange-trans.arr.button-icon}

## How to use



<div class="tabs-box" markdown="1">
{% include programmingLanguageSelectScalaPythonNLU.html %}
```python
document_assembler = DocumentAssembler() \
    .setInputCol("text") \
    .setOutputCol("document")

tokenizer = Tokenizer() \
    .setInputCols(["document"]) \
    .setOutputCol("token")

sequenceClassifier = MedicalBertForSequenceClassification.pretrained("bert_sequence_classifier_vaccine_sentiment", "en", "clinical/models")\
    .setInputCols(["document","token"])\
    .setOutputCol("class")

pipeline = Pipeline(stages=[
    document_assembler, 
    tokenizer,
    sequenceClassifier    
])

text_list = ['A little bright light for an otherwise dark week. Thanks researchers, and frontline workers. Onwards.', 
             'People with a history of severe allergic reaction to any component of the vaccine should not take.', 
             '43 million doses of vaccines administrated worldwide...Production capacity of CHINA to reach 4 b']

data = spark.createDataFrame(text_list, StringType()).toDF("text")
result = pipeline.fit(data).transform(data)
```
```scala
val documenter = new DocumentAssembler() 
    .setInputCol("text") 
    .setOutputCol("document")

val tokenizer = new Tokenizer()
    .setInputCols("document")
    .setOutputCol("token")

val sequenceClassifier = MedicalBertForSequenceClassification.pretrained("bert_sequence_classifier_vaccine_sentiment", "en", "clinical/models")
    .setInputCols(Array("document","token"))
    .setOutputCol("class")

val pipeline = new Pipeline().setStages(Array(documenter, tokenizer, sequenceClassifier))

val data = Seq(Array("A little bright light for an otherwise dark week. Thanks researchers, and frontline workers. Onwards.", 
                     "People with a history of severe allergic reaction to any component of the vaccine should not take.", 
                     "43 million doses of vaccines administrated worldwide...Production capacity of CHINA to reach 4 b")).toDS.toDF("text")

val result = pipeline.fit(data).transform(data)
```
</div>

## Results

```bash
+-----------------------------------------------------------------------------------------------------+----------+
|text                                                                                                 |class     |
+-----------------------------------------------------------------------------------------------------+----------+
|A little bright light for an otherwise dark week. Thanks researchers, and frontline workers. Onwards.|[positive]|
|People with a history of severe allergic reaction to any component of the vaccine should not take.   |[negative]|
|43 million doses of vaccines administrated worldwide...Production capacity of CHINA to reach 4 b     |[neutral] |
+-----------------------------------------------------------------------------------------------------+----------+
```

{:.model-param}
## Model Information

{:.table-model}
|---|---|
|Model Name:|bert_sequence_classifier_vaccine_sentiment|
|Compatibility:|Spark NLP for Healthcare 4.0.0+|
|License:|Licensed|
|Edition:|Official|
|Input Labels:|[document, token]|
|Output Labels:|[class]|
|Language:|en|
|Size:|406.5 MB|
|Case sensitive:|true|
|Max sentence length:|128|

## References

Curated from several academic and in-house datasets.

## Benchmarking

```bash
       label  precision    recall  f1-score   support 
     neutral       0.82      0.78      0.80      1007 
    positive       0.88      0.90      0.89      1002 
    negative       0.83      0.86      0.84       881 
    accuracy       -         -         0.85      2890 
   macro-avg       0.85      0.85      0.85      2890 
weighted-avg       0.85      0.85      0.85      2890 
```
{'fraction_non_alphanumeric': 0.1718590918346569, 'fraction_numerical': 0.0285074322948483, 'mean_word_length': 2.658472998137803, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2375199', 'n_tokens_mistral': 2968, 'n_tokens_neox': 2657, 'n_words': 743}