All Projects → dkesada → dbnR

dkesada / dbnR

Licence: GPL-3.0 license
Gaussian dynamic Bayesian networks structure learning and inference based on the bnlearn package

Programming Languages

r
7636 projects
C++
36643 projects - #6 most used programming language
Jupyter Notebook
11667 projects

Projects that are alternatives of or similar to dbnR

Pmdarima
A statistical library designed to fill the void in Python's time series analysis capabilities, including the equivalent of R's auto.arima function.
Stars: ✭ 838 (+2439.39%)
Mutual labels:  time-series, forecasting
Forecastml
An R package with Python support for multi-step-ahead forecasting with machine learning and deep learning algorithms
Stars: ✭ 101 (+206.06%)
Mutual labels:  time-series, forecasting
Msgarch
MSGARCH R Package
Stars: ✭ 51 (+54.55%)
Mutual labels:  time-series, forecasting
Arch
ARCH models in Python
Stars: ✭ 660 (+1900%)
Mutual labels:  time-series, forecasting
Pyfts
An open source library for Fuzzy Time Series in Python
Stars: ✭ 154 (+366.67%)
Mutual labels:  time-series, forecasting
Darts
A python library for easy manipulation and forecasting of time series.
Stars: ✭ 760 (+2203.03%)
Mutual labels:  time-series, forecasting
Anticipy
A Python library for time series forecasting
Stars: ✭ 71 (+115.15%)
Mutual labels:  time-series, forecasting
Timetk
A toolkit for working with time series in R
Stars: ✭ 371 (+1024.24%)
Mutual labels:  time-series, forecasting
Gluon Ts
Probabilistic time series modeling in Python
Stars: ✭ 2,373 (+7090.91%)
Mutual labels:  time-series, forecasting
Forecasting
Time Series Forecasting Best Practices & Examples
Stars: ✭ 2,123 (+6333.33%)
Mutual labels:  time-series, forecasting
Web Traffic Forecasting
Kaggle | Web Traffic Forecasting 📈
Stars: ✭ 596 (+1706.06%)
Mutual labels:  time-series, forecasting
Introduction To Time Series Forecasting Python
Introduction to time series preprocessing and forecasting in Python using AR, MA, ARMA, ARIMA, SARIMA and Prophet model with forecast evaluation.
Stars: ✭ 173 (+424.24%)
Mutual labels:  time-series, forecasting
Sktime
A unified framework for machine learning with time series
Stars: ✭ 4,741 (+14266.67%)
Mutual labels:  time-series, forecasting
Informer2020
The GitHub repository for the paper "Informer" accepted by AAAI 2021.
Stars: ✭ 771 (+2236.36%)
Mutual labels:  time-series, forecasting
Flow Forecast
Deep learning PyTorch library for time series forecasting, classification, and anomaly detection (originally for flood forecasting).
Stars: ✭ 368 (+1015.15%)
Mutual labels:  time-series, forecasting
Neural prophet
NeuralProphet - A simple forecasting model based on Neural Networks in PyTorch
Stars: ✭ 1,125 (+3309.09%)
Mutual labels:  time-series, forecasting
Luminaire
Luminaire is a python package that provides ML driven solutions for monitoring time series data.
Stars: ✭ 316 (+857.58%)
Mutual labels:  time-series, forecasting
Atspy
AtsPy: Automated Time Series Models in Python (by @firmai)
Stars: ✭ 340 (+930.3%)
Mutual labels:  time-series, forecasting
Statespacemodels.jl
StateSpaceModels.jl is a Julia package for time-series analysis using state-space models.
Stars: ✭ 116 (+251.52%)
Mutual labels:  time-series, forecasting
Java Timeseries
Time series analysis in Java
Stars: ✭ 155 (+369.7%)
Mutual labels:  time-series, forecasting

dbnR

CRAN Status Badge CRAN Downloads Badge License: GPL v3

Introduction

This package offers an implementation of Gaussian dynamic Bayesian networks (GDBN) structure learning and inference based partially on Marco Scutari’s package bnlearn (https://www.bnlearn.com/). It also allows the construction of higher-order DBNs. Three structure learning algorithms are implemented:

Inference is performed either via the particle filtering offered by bnlearn or by doing exact inference over the multivariate Gaussian equivalent of a network implemented in this package. A visualization tool is also implemented for GDBNs and bnlearn’s BNs via the visNetwork package (https://github.com/datastorm-open/visNetwork).

Current development

The main functionality of the package is running and working. In order of importance, the next objectives are:

  • To refractor the DMMHC algorithm into R6 for consistency with the PSOHO algorithm and with any new structure learning algorithms.
  • To add an automatically generated shiny interface of the net. This makes interacting with the network easier and allows for simulation prototypes.

For now, the dbn.fit object as an extension of bnlearn’s bn.fit object will stay the same except for the “mu” and “sigma” attributes added to it. This way, it remains easy to call bnlearn’s methods on the dbn.fit object and I can store the MVN transformation inside the same object. Not an elegant solution, but its simplicity is enough. What should be addressed is having to perform the folding of a dataset outside the predict function.

Getting Started

Prerequisites

This package requires R ≥ 3.6.1 to work properly. It also works for R ≥ 3.5.0, the only difference is the color palette of the DBN visualization tool.

The bnlearn and data.table packages, among others, are required for this package to work. They will be installed automatically when installing this package. They can also be installed manually via CRAN with the command

install.packages(c("bnlearn", "data.table"))

The packages visNetwork, magrittr and grDevices are optional for the visualization tool. They will only be required if you want to use it.

Installing

As of today, the easiest way of installing dbnR is via CRAN. To install it, simply run

install.packages('dbnR')

You can also install the latest version in GitHub with the install_github function in the devtools package. The commands you need to run are

library(devtools)
devtools::install_github("dkesada/dbnR")

This will install the required dependencies if they are not available. After this, you will be ready to use the package.

Basic examples

To get the structure of a GDBN from a dataset, you need to use the function learn_dbn_struc

library(dbnR)
#> Loading required package: bnlearn
#> 
#> Attaching package: 'dbnR'
#> The following objects are masked from 'package:bnlearn':
#> 
#>     degree, nodes, nodes<-, score
data(motor)

size <- 3
dt_train <- motor[200:2500]
dt_val <- motor[2501:3000]
net <- learn_dbn_struc(dt_train, size)

The dt argument has to be either a data.frame or a data.table of numeric columns, in the example we use the sample dataset included in the package. The size argument determines the number of time slices that your net is going to have, that is, the Markovian order of the net. A Markovian order of 1 means that your data in the present is independent of the past given the previous time slice. If your case doesn’t meet this criteria, the size of the net can be increased, to take into account more past time slices in the inference. In our function, Markovian order = size - 1. The function returns a ‘dbn’ object that inherits from the ‘bn’ class in bnlearn, so that its auxiliary functions like ‘arcs’ and such also work on DBN structures.

Once the structure is learnt, it can be plotted and used to learn the parameters

plot_dynamic_network(net)

alt text

f_dt_train <- fold_dt(dt_train, size)
fit <- fit_dbn_params(net, f_dt_train, method = "mle-g")

After learning the net, two different types of inference can be performed: point-wise inference over a dataset and forecasting to some horizon. Point-wise inference uses the folded dt to try and predict the objective variables in each row. Forecasting to some horizon, on the other hand, tries to predict the behaviour in the future M instants given some initial evidence of the variables.

There is an extensive example of how to use the package in the markdowns folder, which covers more advanced concepts of structure learning and inference.

License

This project is licensed under the GPL-3 License, following on bnlearn’s GPL(≥ 2) license.

References

Applications of dbnR

  • Quesada, D., Valverde, G., Larrañaga, P., & Bielza, C. (2021). Long-term forecasting of multivariate time series in industrial furnaces with dynamic Gaussian Bayesian networks. Engineering Applications of Artificial Intelligence, 103, 104301.

  • Quesada, D., Bielza, C., & Larrañaga, P. (2021, September). Structure Learning of High-Order Dynamic Bayesian Networks via Particle Swarm Optimization with Order Invariant Encoding. In International Conference on Hybrid Artificial Intelligence Systems (pp. 158-171). Springer, Cham.

  • Quesada, D., Bielza, C., Fontán, P., & Larrañaga, P. (2022). Piecewise forecasting of nonlinear time series with model tree dynamic Bayesian networks. International Journal of Intelligent Systems, 37, 9108-9137.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].