Text Classification sentiment Simpletransformers deepset/gbert-base de region:us
---
language:
- de
tags:
- Text Classification
- sentiment
- Simpletransformers
- deepset/gbert-base
---




This gBert-base model was finetuned on a sentiment prediction task with tweets from German politician during the German Federal Election in 2021.
## Model Description:
This model was trained on ~30.000 annotated tweets in German language on its sentiment. It can predict tweets as negative, positive or neutral. It achieved an accuracy of 93% on the specific dataset.

## Model Implementation
You can implement this model for example with Simpletransformers. First you have to unpack the file.

    def unpack_model(model_name=''):
      tar = tarfile.open(f"{model_name}.tar.gz", "r:gz")
      tar.extractall()
      tar.close()
      
 The hyperparameter were defined as follows:
     train_args ={"reprocess_input_data": True,
             "fp16":False,
             "num_train_epochs": 4,
             "overwrite_output_dir":True,
             "train_batch_size": 32,
             "eval_batch_size": 32}
             
  Now create the model:
    unpack_model(YOUR_DOWNLOADED_FILE_HERE)

    model = ClassificationModel(
        "bert", "content/outputs/",
        num_labels= 3,
        args=train_args
    )
    
In this case for the output:
- 0 = positive
- 1 = negative
- 2 = neutral
    
Example for a positive prediction:

    model.predict(["Das ist gut! Wir danken dir."])
    ([0], array([[ 2.06561327, -3.57908797,  1.5340755 ]]))

Example for a negative prediction:

    model.predict(["Ich hasse dich!"])
    ([1], array([[-3.50486898,  4.29590368, -0.9000684 ]]))

Example for a neutral prediction:

    model.predict(["Heute ist Sonntag."])
    ([2], array([[-2.94458342, -2.91875601,  4.94414234]]))



This model was created by Maximilian Weissenbacher for a project at the University of Regensburg.