P2G7 / app.py
grcvlrn's picture
Deploy
7786168 verified
Raw History Blame Contribute Delete
5.29 kB
import streamlit as st
import eda
import model
# Sidebar navigation
page = st.sidebar.selectbox(label='Select Page:', options=['Home Page', 'Exploratory Data Analysis', 'Price Prediction'])
if page == 'Home Page':
st.header('Welcome Page')
st.write('')
st.write('Financial News Headline Sentiment Classification')
st.write('Name : Gracia Valerine')
st.write('Batch : HCK 017')
st.write('')
st.caption('Select page')
st.write('')
st.write('')
with st.expander("Summary"):
st.caption("""First of all in making this project is to import all of the libraries. Then, the data will all be loaded onto the notebook. Next is to see the data to understand what we are dealing with. The column names are also changed to understand thoroughly. There are no missing values inside the dataframe, therefore we wont be needig to handle it.
Next is the exploratory data analysis. There are 3 different sentiment that describes the text data, which are neutral, negative, and positive. Mainly the data circles around the neutral one, because financial news needed to be informatical instead of emotional. Also, there are 8 stopwords (unimportant) in the data that will be erased.
There are 20 frequently found words, which are 'UNK', 'eur', 's', 'company', 'mn', 'said', 'finnish', 'sale', 'year', 'share', 'million', 'net', 'profit', 'finland', 'service', 'group', 'operating', 'market', 'business'. Those words will indicate the sentiment for each news headline.
Data Preprocessing starts by cleaning the text (special letters, lowercasing, split words, erasing stopwords, lemmatization (base words)) then turning it into a new column. The target are then change into numbers that represent the values. The data are then split into train set, validation set, and test set with target and feature in each of them. The target is then encoded with one hot encoder for better computerization.
In modeling, we use count vectorize to count the vocabularies, which are later be use for text vectorize to represent the vocabularies and embedded to weigh each vocabularies. The model uses LSTM model bidirectionally so it will be able to do back propagation and dropout to better weigh the vocabularies in order for a better output. The model also has dense 3, because the output we want has 3 different values.
The model is then improved using external embedding layer. This embedding has been trainned before with lots of sample. Also adding early stopping to regularize technique used during the training of machine learning models to prevent overfitting.""")
with st.expander("Conclusion"):
st.caption("""The first model is then evaluated whereas the train set and validation set is quite far off despite the ok accuracy. The model needed to be monitored in training and validation loss/accuracy plots for diagnostics, adjust the hyperparameters and dropout rates based on validation results, and implement techniques like early stopping to prevent overfitting and optimize computational efficiency.
Transfer learning from a pre-trained embedding layer shows a promising performance in text classification tasks.The model shows a moderate accuracy with training accuracy around 63% and validation accuracy around 61-64%. The improvement model needs to be fine-tuning hyperparameters like dropout rates and LSTM units, and continue monitoring metrics such as precision and recall in near future.
Base model is great in simplicity as it's easy to understand. With few parameters are less prone to overfitting and it can benchmark and be a fundemental point to evaluate efficiently. Though, the performance is limited as it is hard to capture the complex relationships and lacking in adavancement as it underperforms and overfits.
Improment model is great because of the enhanced performance. It has high accuracy and better generalization. It also has better technique and optimized parameters. The minimization of overfitting and robust model makes it better than base model. Though, it is complex and hard to understand, risky in overfitting, and needed maintenance regularly. It is still better than base model.
Base model evaluation shows an overfitting in the train and test data and needed better generalization in unseen data. This generalization can be from cross validation, regularization, and diverse data.Meanwhile, improvement model evaluation shows a less overfitting in the train and test data and needed data augmentation.""")
with st.expander('Recommendation'):
st.caption("""The model is made as an initial benchmark for model selection in machine learning.This can create clear objectives to predict stock movements and actionable insights to strategize business movements.
- Business can use this as market research to provide insights for investors and market reaction to pick out next movement.
- Business can use this as risk management by identifying negatives to indicate potential risks and market downturns for financial loss mitigation.
- Business can also get customers insights by gauging on public sentiment on companies, products, and market trends for a customer targeted business movement.""")
elif page == 'Exploratory Data Analysis':
eda.run()
else:
model.run()