GithubHelp home page GithubHelp logo

neuralprophet's Introduction

neuralprophet

CRAN_Status_Badge R-CMD-check

The NEW Neural Prophet arrives to R!

# Install Development Version 
remotes::install_github("AlbertoAlmuinha/neuralprophet")

Not on CRAN yet:

#install.packages("neuralprophet")

Neural Prophet Algorithm

Using neural_prophet(), which connects to Python NeuralProphet().

library(neuralprophet)
library(tidymodels)
library(tidyverse)
library(timetk)

m <- m4_monthly %>% filter(id == "M750")

splits <- initial_time_split(m)


model_fit_nprophet <- neural_prophet(
    freq            = "M",
    growth          = "linear",
    trend_reg       = 3,
    learn_rate      = 0.1,
    changepoint_range = 0.8,
    seasonality_mode = "additive"
) %>%
    set_engine("prophet") %>%
    fit(value ~ ., training(splits))

# Forecast with 95% Confidence Interval
modeltime_table(
    model_fit_nprophet
) %>%
    modeltime_calibrate(new_data = testing(splits)) %>%
    modeltime_forecast(
        new_data      = testing(splits),
        actual_data   = m,
        conf_interval = 0.95
    ) %>%
    plot_modeltime_forecast(.interactive = FALSE)

Installation

There are 2 key components to installing neuralprophet:

  1. Download the R-Package, neuralprophet. This installs the R-Bindings, which allows you to interface with NeuralProphet

  2. Set up the Python Environment so neuralprophet can connect to the neuralprophet python package.

Step 1 - Download & Install neuralprophet

Download the latest development version.

remotes::install_github("AlbertoAlmuinha/neuralprophet")

Step 2 - Python Environment Setup

Next, you’ll need to set up a Python Environment that contains at a minimum:

  • neuralprophet==0.2.7
  • pillow==8.3.0
  • pandas==1.2.5
  • numpy
  • pytorch==1.6

The python environment then needs to be activated with reticulate.

Fast Setup

You can use install_nprophet() to prepare and bind to a python environment containing neuralprophet and the required python packages.

  • You only need to run this one time, and then you are good to go.
  • Each time you load neuralprophet, the package will include this environment in it’s search process.
# Neural Prophet Installation - Run 1st time
install_nprophet()

Step 3 - Restart R and Try an Example

Restart your R session (if in RStudio, close and re-open). Then try this example.

library(neuralprophet)
library(tidymodels)
library(tidyverse)
library(timetk)

m <- m4_monthly %>% filter(id == "M750")

splits <- initial_time_split(m)


model_fit_nprophet <- neural_prophet(
    freq            = "M",
    growth          = "linear",
    trend_reg       = 3,
    learn_rate      = 0.1,
    changepoint_range = 0.8,
    seasonality_mode = "additive"
) %>%
    set_engine("prophet") %>%
    fit(value ~ ., training(splits))

# Forecast with 95% Confidence Interval
modeltime_table(
    model_fit_nprophet
) %>%
    modeltime_calibrate(new_data = testing(splits)) %>%
    modeltime_forecast(
        new_data      = testing(splits),
        actual_data   = m,
        conf_interval = 0.95
    ) %>%
    plot_modeltime_forecast(.interactive = FALSE)

Troubleshooting Installation

Python Environment setup is always fun. Here are a few recommendations if you run into an issue.

  • Check to make sure Conda or Miniconda is available using reticulate::conda_version(). If no conda version is returned, then use reticulate::install_miniconda() to install Miniconda (recommended vs full Aniconda). Then (re-)run install_gluonts().

  • Check if Neural Prophet (Python) is available using reticulate::py_module_available("neuralprophet"). If this returns TRUE, then your installation has succeeded in building the environment, but you may have other issues like missing C++ build tools (next).

  • Windows 10 error: Microsoft Visual C++ is required. Here are the instructions for installing the C++ tools needed.

  • Other installation issues. Please file a GitHub issue here.

neuralprophet's People

Contributors

albertoalmuinha 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.