Git Product home page Git Product logo

luisosorio3214 / microsoft-stock-analysis Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 2.62 MB

Microsoft Stock Deep Learning Model Prediction and Story Timeline Analysis.

Home Page: https://luisosorio3214.github.io/Power-BI-Dashboards/Microsoft%20Stock/

dashboard deep-learning gated-recurrent-unit github-pages html-css long-short-term-memory markdown microsoft powerbi r stock-market storytelling yahoo-finance

microsoft-stock-analysis's Introduction

Microsoft Stock Analysis

Badge Source

Authors

Table of Contents

Context

I like to study macro-economics and it is quite essential when reading stock market prices since they are heavily influenced by it. It is quite remarkable how a single statement from the Federal Reserve chairman, Jerome Powell and the entire stock price completely changes course. I usually spend time watching the Fed Minutes and also find interesting how several news outlets ask Jerome tricky questions to pull more information to expose hidden truths. The motivation for this particular project was to use Microsoft Stock prices and relate them to historical events that have impacted our economy to tell a compelling story about tech and economics. I also wanted to build some deep learning models to see if I can try to predict the movement of the stock price.

Data Source

Methods

  • Data Preprocessing
  • Deep Learning Modeling
  • Power BI
  • App Deployment

Tech Stack

  • R (Deep Learning modeling)
  • Power BI (Dashboard creation)
  • HTML/CSS (website)
  • GitHub Pages (web app deployment)

Quick Glance at Deep Learning Results

Long Short Term Memory - Prediction Plot

Gated Recurrent Unit - Predict Plot

Deep Learning Algorithms Results

Model Mean Absolute Error Mean Squared Error Root Mean Squared Error
Long Short Term Memory (LSTM) 15.46492 314.6245 17.73766
Gated Recurrent Unit 8.10126 92.75793 9.631092

  • Activation Function Used: tanh
  • Loss Function: Mean Squared Error
  • Metric Used: Mean Squared Error
  • Best Model: Gated Recurrent Unit
  • Why use Mean Squared Error: Observe that the goal of this project was for our deep learning model to predict the closing price of the stock for that day. We were dealing with a regression problem and metrics such as F1-Score, Recall, and accuracy do not make sense in this scenario. Now, Mean Squared Error value represents the average squared difference between the predicted values and the actual values. Since we are taking the average squared difference, MSE can never be negative and the lower the MSE the more indication that the model performed a better fit to the data. Now if we take the square root of the mean squared error, we get the root mean squared error which takes the same units of the actual data. In short hand, its similar in metric but it is more interpretable and easier to compare to the actual data. For example, we can say for GRU model which had the best mean squared error compared to the two had a root mean squared error of about 9.63 thus we can say on average the predicted price was about $9.63 away from the actual price. This where we can take the standard deviation to make a confidence interval if we truly wanted to.

Lessons Learned and Recommendation

  • The biggest lesson learned in this project was the difficulty in setting up a deep learning environment in R Studio. I did not know that it the end it uses python and same libraries such as tensorflow and keras. I would never work with deep learning models in R again since I already have working knowledge in python, my preferred programming language. However, R still reigns supreme when it comes down to statistical analysis and still conduct many of my hypothesis tests in R along some Linear/Logistic Regressions.
  • Another major lessons learned was to properly chose the number of epochs (steps to train the model) since we can potentially over fit the model. Over fitting the model would imply a low bias but high variance meaning our testing set predictions we be far off for our actual values. We want the perfect balance between bias and variance.

Limitation and what can be Improved

  • Now we tested the validity of our model using a testing set which was stored apart from the data in which our model was trained on. This provides us no new information since we already know the values of the testing set. Now Suppose we wanted to predict the closing price for a date in the future, then we simply create a data frame containing the date of the day and feed into our model giving us a value. Now stock prices are influence by a multitude of factors and no one can really predict a Black Swan Event which can heavily influence a price. For example, Covid caused many stocks to crash and no one expected a worldwide shut down because of it. Therefore, a deep learning model will never be able to fully predict a closing price. There's companies that take many factors into consideration and place them in their models such as tweets from influencer, market sentiment, and stock technical analysis.

R Markdown

To see the full R Markdown notebook click here.

Checkout the Website with dashboard

To read full Microsoft Stock Analysis with a story relating to tech and economics click here.

Deployment using GitHub Pages

Did you know you can deploy a website for free using GitHub Pages? I will teach you step by step on how to deploy your own website.

  1. First Create a GitHub Repository
  2. Next build your website using your HTML code and name the file index.html. Note: You do not have to name the html file index however it will make it easier when directing to your site.
  3. Next, go to your repository settings. Go to Pages.
  4. Under the Branch title, where it says None click and choose the branch in which your repository is using. For most it will be the Main Branch.
  5. You can view the deployment process under the GitHub Actions. This is where you can customize your own build process which is a whole course in itself.
  6. After some time, in the pages setting a link appear. This is the website to your html file.

Website Deployed

Video to gif tool

Contribution

Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change or contribute.

License

MIT License

Copyright (c) 2022 Stern Semasuka

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.

Learn more about MIT license

microsoft-stock-analysis's People

Contributors

luisosorio3214 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.