Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit


 

 

Project Description

 

Before you turn this problem in, make sure everything runs as expected. First, restart the kernel (in the menubar, select Kernel!Restart) and then run all cells (in the menubar, select Cell!Run All).

Make sure you fill in any place that says YOUR  CODE HERE or “YOUR ANSWER HERE”, as well as your name and collaborators below:

[  ]:  NAME  =  ""

ID  =  ""

 

 

 

1   Python for Finance Project:  Financial  Statement  Sentiment Analysis

 

DDL: Dec 18th, 2021

Please noted, you are not allow to use packages that are from outside of this course

Dr. Pengfei Zhao

Finance Mathematics Program,

BNU-HKBU United International College

 

1.1   1. Why sentiment analysis?

1.1.1   1.1 Understanding Sentiment Analysis

• Sentiment analysis,  also known as opinion mining,  refers to the use of natural language processing, text analysis and computational linguistics to identify and extract subjective information in source materials. (Wikipedia)

 

1.1.2   1.2 How to do Sentiment Analysis?

• A simple solution is,  every word is given a score based on its extent of positiveness, negativeness or neutral.  The Sentiment Analysis is done by calculating the algorithmic score of each word, and returning with the combined score for the given set of text.


1.1.3   1.3 How Can The Sentiment Analysis API Be Applied In Financial Sector?

• The most common use of The Sentiment Analysis in financial sector will be the analysis of financial news, in particular to predicting the behaviour and possible trend of stock markets.

• Traditional Technical Analysis of the Financial Market with the use of tools the like of Stock- astics and Bollinger bands aside, sentiment analytics has been receiving a lot of attention as it allows the integration of both Fundamental Analysis (FA) and Technical Analysis (TA).

• In real life, Financial Market Analysts make predictions on the stock market based on opinions and happenings in the news.  Similarly, Sentiment Analysis technique is making it possible for computers to do the same job now. Further more, with advance computational linguistic and machine learning techniques, the task of opinion mining proves to be more efficient than human analysts, having the capability to scan through huge chunk of text across various news channels within seconds.

• A simple example of the real application of Sentiment Analysis for the financial sector can be explained by the task of assigning positive, negative or neutral sentiment values to the words. For instance, words such as good, benefit, positive, increase and growth are all tagged with positive scores while words such as decrease, risk, fall, bankruptcy, and loss are tagged with negative scores.

 

1.1.4   1.4 The Trend Of Sentiment Analysis

• Sentiment Analysis has been heavily used by businesses for social media opinion mining, especially in the service industry, where customers feedback are critical.  In recent years, it has been gaining popularity in the finance sector, where it has been used to analyze tweets of influential financial analysts and decision makers.  It seems like there are so much potential to be unlocked for the usage of Sentiment Analysis.  It is curious to what will be the next breakthrough!

 

1.2   3. What you need to do in this project

1.2.1   3.1 What is already given

• train.txt:  contains 3877 rows with 3 columns “index”, “sentiment”, “text”, where “text” denotes the financial news sentence,  “sentiment” denotes the human annotated sentiment result  (3 categories  “positive”,  “negative”,  “neutral”), and  “index” denotes the ID of the news sentence.

•  test_x.txt: contains 970 rows with 2 columns “index” and “text” whose explanation is the same as “train.txt”.

•  senti_dict.csv: The sentiment word dictionary, where the value of each word indicates how positive of a word is.  Negative score means the word tends to be negative.  Note that this word sentiment dictionary is not guaranteed to be thorough and complete.

•  fyi folder: resources you may be interested in.


1.2.2   3.2 What you need to submit

You need to submit a zipped package containing following files:

• test_y.txt. You need to put your prediction results in a file named as “test_y.txt”. The file contains 970 rows with 2 columns, in the form of index,label.  “index” denotes the ID of corresponding sentence in “text_x.txt”, and “label” denotes the sentiment you predict with respect to that sentence, which should be “positive”, “negative”, or “neutral”.

•  .ipynb  file.  You need to implement your solution in this jupyter notebook file, and add sufficient introduction to your thoughts and program (e.g. use highlight, bulletin, etc, just like the lecture slides), using the markdown language.

Important: your .ipynb file should be able to output (write) the “test_y.txt” to hard disk. If there is only the prediction result (test_y.txt) and your .ipynb file does not include the code which can output the prediction result, you will get zero marks. I will go into the .ipynb file and run each cell of your program.  So, make sure your .ipynb is well organized so that I can easily find the part which can output your prediction result.

•  sentiment_words_dict.txt  (optional).  If you use your own sentiment dictionary in the solution, you need to submit the dictionary used in your project as well.

• In all, you need to submit all the materials so that I can successfully run your code and obtain the prediction result.

 

1.2.3   3.3 How to grade

• Project score will be based on:

(1) The accuracy of your prediction result (test_y.txt).  Accuracy is calculated based on how many labels you correctly predicted.

(2) Your code and explanation written in the ipynb file.

 

1.2.4   3.4 Hints

•  You can use the sentiment in train.txt to validate your prediction strategy.

•  You can use the word sentiment score in senti_dict.csv to calculate the overall sentiment score of a sentence.

•  There   has   many   sentiment   words   dictionary   available   online   besides   the   provided ‘senti_dict.csv’, you can download the dictionary and use it in your projects.

• You can use mark  down to better edit your .ipynb file, e.g. add highlights, bold/italic font, images, tables, etc.  You need to first set the cell as Markdown mode, instead of the  Code mode. Markdown tutorial see here and here.

 

1.2.5   3.5 For Your Interest

• Sentiment analysis technique have been widely applied to finance sector. Even though in this project you may only use the provided sentiment dictionary to judge the sentiment score of


an article, in real world Artificial Intelligence (AI) and machine learning technique are largely used (e.g. to “learn” the sentiment score of each word). You can read more here.

• In 2011, a paper “Twitter mood predicts the stock market” (in ./fyi/ folder) draws great attention.  People realize that the public sentiment may even influence the trend of stock price. Altough the effectiveness of applying sentiment analysis to stock price prediction task in this paper is doubted by other researchers later, sentiment analysis gradually becomes a widely accepted factor to facilitate analyse business. For example, below figure is a snapshot of “ffffffff”, and “ffffffff” becomes a standard component facilitating investors to analyse stock.

 

String Index    String Methods

 

 

 

[  ]: