This is the combined workflow for web scraping, performing sentiment analysis, and saving this all to a .csv file and the MongoDB database. When collecting data, we ran this file every day. This has not been automated.
This performs and evaluates logistic regression on the stock data based on the sentiment analysis values obtained from web-scraped current news articles.
This performs long short-term memory modeling with neural networks to predict stock market changes—increase or decrease—based on historical financial data and sentiment analysis on current news articles.
This performs simple autoregressive prediction on the stock data based on the sentiment analysis data and prediction values from the previous two days. It is important to note that the model performance was significantly affected by data sparsity, as it is highly dependent on past data to make future predictions.
For modeling and data manipulation, sometimes it is better to use the datetime object for efficiency instead of the date as a string. This file allows for these conversions, if necessary.
This file produces plots of the distribution of stocks across the sectors. It also allows us to make plots of sentiment vs. price of stock for a chosen stock
This file builds a web scraper that—given an article title and URL from the Yahoo Finance API—accesses, scrapes, and stores the corresponding article text as a list of strings
Based on the web scraper implemented in yahoo_finance_news_scraper.ipynb, this file stores the scraped article text in a pandas dataframe and uploads the data into our MongoDB database for storage and future reference.
This is a local copy of the stock data used to train models, so we don’t have to pull from the database every time.
Follow these steps to set up the project on your local machine.
Before you begin, ensure that you have the following installed:
- Python: Download and install the latest version of Python from python.org.
- pip: Python's package installer, which typically comes pre-installed with Python. You can verify by running
pip --version.
First, clone the repository to your local machine using the following command:
$ git clone https://github.com/cc459/Predictive-Analysis.git
$ cd Predictive-Analysis
For Mac/Linux:
$ python3 -m venv venv
For Windows:
$ python -m venv venv
For Mac/Linux:
$ source venv/bin/activate
For Windows:
$ venv\Scripts\activate
If the activation is successful, you should see (venv) at the start of your terminal prompt.
With the virtual environment active, install all necessary dependencies:
$ pip install -r requirements.txt
Once you're done working, you can deactivate the virtual environment by running
$ deactivate
If you add new packages during development, please update the requirements.txt file:
$ pip freeze > requirements.txt
This ensures that anyone else working on the project will have access to the updated dependencies.
*If you are facing issues running the code, specifically ModuleNotFoundErrors, simply download the module indicated that isn't installed using the command "pip install <module_name>" in terminal.