Skip to main content

VADER sentiment classifier updated with financial lexicons

Project description

pypi python License: MIT

FinVADER

VADER sentiment classifier updated with financial lexicons

VADER (Valence Aware Dictionary and sEntiment Reasoner) classifier is a mainstream model for sentiment analysis using a general-language human-curated lexicon, including linguistic features expressed on social media. As such, the model works worse on texts that use domain-specific language, such as finance or economics.

FinVADER improves VADER's classification accuracy, including two finance lexicons: SentiBignomics, and Henry's word list. SentiBigNomics is a detailed financial lexicon for aspect-based sentiment analysis with approximately 7300 terms containing a polarity score ranging in [-1,1] for each item. Henry's lexicon covers 189 words appearing in the company earnings press releases.

FinVADER outperforms VADER on Financial PhraseBank data:

finvader_accuracy vader_accuracy

The code for this benchmark test is here


Installation

FinVADER requires Python 3.8 - 3.11, and NLTK.

To install using pip, use:

pip install finvader

Data requirements

It requires complete text data without NaN values and empty strings. Remove them in the pre-processing part.

Usage

  • Import the library:
from finvader import finvader
  • Select lexicons:
def finvader(text = 'str',                    # Text
             indicator = 'str',               # VADER's indicator: 'pos'/'neg'/'neu'/'compound' 
             use_sentibignomics: bool= False, # Use SentiBignomics lexicon
             use_henry: bool= False):         # Use Henry's lexicon
) 
  • Use the classifier:
text = "The period's sales dropped to EUR 30.6 m from EUR 38.3 m, according to the interim report, released today."

scores = finvader(text, 
                  use_sentibignomics = True, 
                  use_henry = True, 
                  indicator = 'compound' )

Documentation, examples and tutorials

Example of using the classifier:

import pandas as pd                                            # read data
data = pd.read_csv("ecb_speeches.csv")
from finvader import finvader                         
data['finvader'] = data.contents.apply(finvader,               # apply FinVADER and create a new column in data df
                                   use_sentibignomics = True,  # Use Lexicon 1
                                   use_henry = True,           # Use Lexicon 2
                                   indicator="compound")       # Use VADER's compound indicator

For examples of coding, read these tutorials:

FinVADER: Sentiment Analysis for Financial Applications here

Fine-tuning VADER Classifier with Domain-specific Lexicons here


Please visit here for any questions, issues, bugs, and suggestions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

finvader-1.0.4.tar.gz (45.9 kB view details)

Uploaded Source

Built Distribution

finvader-1.0.4-py3-none-any.whl (45.2 kB view details)

Uploaded Python 3

File details

Details for the file finvader-1.0.4.tar.gz.

File metadata

  • Download URL: finvader-1.0.4.tar.gz
  • Upload date:
  • Size: 45.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for finvader-1.0.4.tar.gz
Algorithm Hash digest
SHA256 4d1037dd4efbd4f7af47bcc1eb8d7f76d0a19c14d2991a4b067996ebfc146cbc
MD5 f16f386f5100be6e85125e86c39eff1f
BLAKE2b-256 9427b5f343f3f1b3f09166577d8b99a8fe8d26e50862ae9d26ee82e84dd070ce

See more details on using hashes here.

File details

Details for the file finvader-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: finvader-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 45.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for finvader-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1558fd5ed1348ab5f9e19f1d106c3fab97112b7fc0481998d0395195ab9351d8
MD5 5cfa40849218388b19000eaaade50c08
BLAKE2b-256 5283ec431440a565eb5f38e57949c9e7476ee04e44fba8ae5b91ffcfbf1d55a4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page