GithubHelp home page GithubHelp logo

aeon's Introduction

aeon

CRAN status Buy hex stciker

Time Series models for keras in R

Installation

You can install the development version of aion from GitHub with:

# install.packages("devtools")
devtools::install_github("krzjoa/aion")

Key features

  • Temporal Fusion Transformer model
  • additional layers: Temporal Convolutional Network block & Legendre Memory Unit
  • make_array and ts_generator functions to quickly prepare input/output for {keras} time series models
  • new loss functions: loss_quantile, loss_tweedie and loss_negative_log_likelihood

Usage

# Dataset
library(m5)

# Neural Networks
library(aion)
library(keras)

# Data wrangling
library(dplyr, warn.conflicts=FALSE)
library(data.table, warn.conflicts=FALSE)
library(recipes, warn.conflicts=FALSE)

# ==========================================================================
#                          PREPARING THE DATA
# ==========================================================================

train <- tiny_m5[date < '2016-01-01']
test  <- tiny_m5[date >= '2016-01-01']

m5_recipe <-
  recipe(value ~ ., data=train) %>%
  step_mutate(item_id_idx=item_id, store_id_idx=store_id) %>%
  step_integer(item_id_idx, store_id_idx,
               wday, month,
               event_name_1, event_type_1,
               event_name_2, event_type_2,
               zero_based=TRUE) %>%
  step_naomit(all_predictors()) %>%
  prep()

train <- bake(m5_recipe, train)
test  <- bake(m5_recipe, test)

TARGET      <- 'value'
STATIC      <- c('item_id_idx', 'store_id_idx')
CATEGORICAL <- c('event_name_1', 'event_type_1', STATIC)
NUMERIC     <- c('sell_price', 'sell_price')
KEY         <- c('item_id', 'store_id')
INDEX       <- 'date'
LOOKBACK    <- 28
HORIZON     <- 14
STRIDE      <- LOOKBACK
BATCH_SIZE  <- 32

# ==========================================================================
#                          CREATING GENERATORS
# ==========================================================================

c(train_generator, train_steps) %<-%
    ts_generator(
        data        = train,
        key         = KEY,
        index       = INDEX,
        lookback    = LOOKBACK,
        horizon     = HORIZON,
        stride      = STRIDE,
        target      = TARGET,
        static      = STATIC,
        categorical = CATEGORICAL,
        numeric     = NUMERIC,
        batch_size  = BATCH_SIZE    
  )

c(test_generator, test_steps)  %<-%
    ts_generator(
        data = test,
        key = KEY,
        index = INDEX,
        lookback = LOOKBACK,
        horizon = HORIZON,
        stride = STRIDE,
        target=TARGET,
        static=STATIC,
        categorical=CATEGORICAL,
        numeric=NUMERIC
    )

Package name

The package was initially named aion. However, I was waiting so long with publishing it and somebody has beaten me to it.

aeon's People

Contributors

krzjoa avatar

Stargazers

 avatar

Watchers

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