- This project aims to predict the topic of a given news article using Latent Semantic Analysis (LSA) and Latent Dirichlet Allocation (LDA).
- It also compares the performance of both algorithms using t-Distributed Stochastic Neighbor Embedding (TSNE) to plot the clusters.
- The project leverages the Newspaper3K library to fetch news articles, Flask for the web interface, and FinBERT for financial sentiment analysis.
- To ensure efficiency, multiprocessing is used to run each model as a separate process.
- The ABC "A Million News Headlines" dataset is used to train the models.
- Topic Prediction: Predicts the topic of a given news article using LSA and LDA by spitting out predicted keywords.
- Web Interface: Intuitive web interface to interact with the Flask server.
- Multiprocessing: Runs each model as a separate process to enhance efficiency.
- Sentiment Analysis: Uses FinBERT API to predict the sentiment of the news article.
- Automatic Data Fetching: Uses Kaggle's CroissantML format to automatically download and store the data in parquet format.
- Create a
config.json
file in the root directory of the project. The structure of the file must match that ofexample_config.json
. - [Optional] Create a virtual python environment and initialize it.
- Install the project requirements by running the following command
pip install -r requirements.txt
.- Note that this project requires Python 3.11.8 and on some systems you must run
pip3 install -r requirements.txt
.
- Note that this project requires Python 3.11.8 and on some systems you must run
Bokeh was used to generate the following plots:
- LSA:
- LDA:
Unsurprisingly, LDA does a better job at separating the articles into clusters.
- Change into the project directory and start the server by
python .
orpython3 .
- Access the web interface at
http://127.0.0.1:{PORT FROM config.json}
.
- This example uses the following link:
- This example uses the following link, which blocks the download:
- This example uses the following link:
MIT License
Copyright (c) 2024
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.