Giter Site home page Giter Site logo

ai-to-the-moon / timeseries_modelingwithprophet Goto Github PK

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

This Jupyter Notebook explores revenue, search, and stock price trends for MercadoLibre and utilizes predictive modeling power from Prophet to make future predictions

Jupyter Notebook 100.00%

timeseries_modelingwithprophet's Introduction

Time Series Modeling with Fbprophet

This Jupyter Notebook explores time series trends (search, stock price, revenue) for MercadoLibre and uses the fbprophet package to make future predictions.

Google Colab was used in the development of this Jupyter Notebook.

Technologies

This program is written in Python (3.7.13) and developed using Google Colab on a Windows computer. Additional libraries that are used in this application are pandas (1.3.5), hvplot (0.8.0), seaborn (0.11.2), pystan(2.19.1.1), holoviews(1.14.9), and numpy (1.21.6) (see parenthesis for versions used in program development).

In your Google Colab environment, these lines of code should be sufficient for you to get started.

!pip install pystan
!pip install fbprophet
!pip install hvplot
!pip install holoviews

If you experience errors with the install for fbprophet, try Mokey Luffy's solution from stackoverflow:

!pip install pystan ~= 2.14
!pip install fbprophet

Installation Guide

Downloading the code & associated files using git clone from the repository is sufficient to download the Jupyter Notebook, ensure that the associated libaries (see Technologies section) are installed on your machine (or in the Google Colab environment) as well. If there are any issues with the library functions please refer to the versions used for app development (see Technnologies section for this information as well). Please note that this is a Jupyter notebook.

The code in the notebook is written for the Google Colab environment, there are a few lines of code that you may want to take out if running it on your local machine, such as the lines for !pip install, the lines to display hvplots in the Colab environment hv.extension('bokeh'), and the lines for file uploads, which are from google.colab import files and uploaded = files.upload().

Usage

This notebook is referencing data stored in the Resources folder in the repository. As described above, including these lines of code in your notebook will prompt you to add the files to your Google Colab environment:

from google.colab import files
uploaded = files.upload()

If you're not using Google Colab, in the pd.read_csv functions, make sure to specify the correct path to the files.

Code examples

The hvPlot library is used to display multiple different types of charts (such as line charts, bar charts, and heatmaps) to view and analyze the data. Displaying information using hvPlot is simple and can be done with only one line of code such as:

df.hvplot(title="my chart")

A few calculations are done using grouping and group levels, for example:

groupby_levels = [df_mercado_trends.index.year, df_mercado_trends.index.month]
median_monthly_traffic = df_mercado_trends.groupby(by=groupby_levels).sum().median()

The fbprophet package is used to make forecasts on the time series data. The Prophet() function accepts an input dataframe with two columns named ds (for the independent variable) and ys (for the predicted variable).

Creating a model, making predictions, exploring trends, and viewing the data can be done with only a few lines of code:

model = Prophet()
model.ft(df)
future_predictions = model.make_future_dataframe(periods=2000, freq="H")
forecast_trends = model.predict(future_predictions)
model.plot(forecast_trends)
forecast_trends = forecast_trends.reset_index()
model.plot_components(forecast_trends)

The forecast_trends dataframe presents you with multiple columns: in this analysis, yhat is used for the best estimate, yhat_upper is used to represent the best case scenario, and yhat_lower is used to represent the worst case scenario.

References

For more information about the libraries, check out the documentation!

Hvplot library

Fbprophet library

Contributors

Project contributors are the Rice FinTech bootcamp program team (instructor Eric Cadena) who developed the tasks for this project along with myself (Paula K) who's written the code in the workbook.

timeseries_modelingwithprophet's People

Contributors

ai-to-the-moon 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.