SysIdentPy

SysIdentPy: A Python package for System Identification using NARMAX models - Published in JOSS (2020)

https://github.com/wilsonrljr/sysidentpy

Science Score: 93.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 8 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: joss.theoj.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

data-science dynamical-systems machine-learning narmax narx system-identification time-series

Scientific Fields

Mathematics Computer Science - 84% confidence
Last synced: 6 months ago · JSON representation

Repository

A Python Package For System Identification Using NARMAX Models

Basic Info
  • Host: GitHub
  • Owner: wilsonrljr
  • License: bsd-3-clause
  • Language: Python
  • Default Branch: main
  • Homepage: https://sysidentpy.org
  • Size: 249 MB
Statistics
  • Stars: 459
  • Watchers: 14
  • Forks: 90
  • Open Issues: 10
  • Releases: 20
Topics
data-science dynamical-systems machine-learning narmax narx system-identification time-series
Created almost 7 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Contributing Funding License Code of conduct Authors Zenodo

README.md

[![DOI](https://img.shields.io/badge/DOI-10.21105%2Fjoss.02384-%23FF7800)](https://joss.theoj.org/papers/10.21105/joss.02384) [![PyPI version](https://img.shields.io/pypi/v/sysidentpy?color=%23ff7800)](https://pypi.org/project/sysidentpy/) [![License](https://img.shields.io/pypi/l/sysidentpy?color=%23FF7800)](https://opensource.org/licenses/BSD-3-Clause) [![openissues](https://img.shields.io/github/issues/wilsonrljr/sysidentpy?color=%23FF7800)](https://github.com/wilsonrljr/sysidentpy/issues) [![issuesclosed](https://img.shields.io/github/issues-closed-raw/wilsonrljr/sysidentpy?color=%23FF7800)](https://github.com/wilsonrljr/sysidentpy/issues) [![downloads](https://img.shields.io/pypi/dm/sysidentpy?color=%23FF7800)](https://pypi.org/project/sysidentpy/) [![python](https://img.shields.io/pypi/pyversions/sysidentpy?color=%23FF7800)](https://pypi.org/project/sysidentpy/) [![status](https://img.shields.io/pypi/status/sysidentpy?color=%23FF7800)](https://pypi.org/project/sysidentpy/) [![discord](https://img.shields.io/discord/711610087700955176?color=%23FF7800&label=discord)](https://discord.gg/7afBSzU4) [![contributors](https://img.shields.io/github/contributors/wilsonrljr/sysidentpy?color=%23FF7800)](https://github.com/wilsonrljr/sysidentpy/graphs/contributors) [![stars](https://img.shields.io/github/stars/wilsonrljr/sysidentpy?style=social)](https://github.com/wilsonrljr/sysidentpy/stargazers)

NARMAX Methods For System Identification and TimeSeries Forecasting

From Classical Approaches to Neural Networks

**SysIdentPy** offers State-of-the-Art techniques to build your NARMAX models, including its variants `NARX`, `NARMA`, `NAR`, `NFIR`, `ARMAX`, `ARX`, `ARMA` and others. It also includes tons of interesting examples to help you build nonlinear forecasting models using SysIdentPy.

Table of Contents

Introduction

SysIdentPy is an open-source Python module for System Identification using NARMAX models built on top of numpy and is distributed under the 3-Clause BSD license. SysIdentPy provides an easy-to-use and flexible framework for building Dynamical Nonlinear Models for time series and dynamic systems.

With SysIdentPy, you can:

  • Build and customize nonlinear forecasting models.
  • Utilize state-of-the-art techniques for model structure selection and parameter estimation.
  • Experiment with neural NARX models and other advanced algorithms.

Check our documentation!

For an in depth documentation, check our companion book:

Nonlinear System Identification

How do I install SysIdentPy?

The easiest way to get SysIdentPy running is to install it using pip console pip install sysidentpy

Requirements

SysIdentPy requires:

  • Python (>= 3.8) (3.7 works for everything except for 3 parameter estimation methods)
  • NumPy (>= 1.9.2) for numerical algorithms
  • Matplotlib >= 3.3.2 for static plotting and visualizations
  • Pytorch (>=1.7.1) for building NARX neural networks
  • scipy (>= 1.8.0) for numerical and optimization algorithms

The library is compatible with Linux, Windows, and macOS. Some examples may also require additional packages like pandas.

For more details, check our installation guide

What are the main features of SysIdentPy?

| Feature | What is this? | |----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | NARMAX philosophy | You can build variations of NARMAX models like NARX, NAR, NARMA, NFIR, ARMA, ARX, AR, and others. | | Model Structure Selection | Easy-to-use methods to select the best terms to build your models, including FROLS and MetaMSS and several combinations with parameter estimation techniques to select the model terms. | | Basis Function | You can use up to 8 different basis functions to build your models. You can set linear and nonlinear basis functions and ensemble them to get custom NARMAX models. | | Parameter Estimation | More than 15 methods to estimate the model parameters and test different structure selection scenarios. | | Multiobjective Parameter Estimation | You can use affine information to estimate the model parameters minimizing different objective functions. | | Model Simulation | You can reproduce results from papers easily with SimulateNARMAX class. Moreover, you can test published models with different parameter estimation methods and compare the performance. | | Neural NARX | You can use SysIdentPy with Pytorch to create custom neural NARX models architectures which support all the optimizers and loss functions from Pytorch. | | General Estimators | You can use estimators from packages like scikit-learn, Catboost, and many other compatible interfaces and composition tools to create NARMAX models. |

Why does SysIdentPy exist?

SysIdentPy aims to be a free and open-source package to help the community to design NARMAX models for System Identification and TimeSeries Forecasting. More than that, be a free and robust alternative to one of the most used tools to build NARMAX models, which is the Matlab's System Identification Toolbox.

The project is actively maintained by Wilson R. L. Junior and looking for contributors.

How do I use SysIdentPy?

The SysIdentPy documentation includes more than 20 examples to help get you started: - Quickstart guide, for an entry-level description of the main SysIdentPy concepts - A dedicated section focusing on SysIdentPy features, like model structure selection algorithms, basis functions, parameter estimation, and more. - A dedicated section focusing on use cases using SysIdentPy with real world datasets. Besides, there is some brief comparisons and benchmarks against other time series tools, like Prophet, Neural Prophet, ARIMA, and more.

Examples

```python from torch import nn import numpy as np import pandas as pd import matplotlib.pyplot as plt from sysidentpy.metrics import rootrelativesquarederror from sysidentpy.utils.generatedata import getsisodata

Generate a dataset of a simulated dynamical system

xtrain, xvalid, ytrain, yvalid = getsisodata( n=1000, colorednoise=False, sigma=0.001, trainpercentage=80 ) ```

Building Polynomial NARX models with FROLS algorithm

```python from sysidentpy.modelstructureselection import FROLS from sysidentpy.basisfunction import Polynomial from sysidentpy.parameterestimation import LeastSquares from sysidentpy.metrics import rootrelativesquarederror from sysidentpy.utils.generatedata import getsisodata from sysidentpy.utils.displayresults import results from sysidentpy.utils.plotting import plotresiduescorrelation, plotresults from sysidentpy.residues.residuescorrelation import ( computeresiduesautocorrelation, computecross_correlation, )

basisfunction = Polynomial(degree=2) estimator = LeastSquares() model = FROLS( orderselection=True, ninfovalues=3, ylag=2, xlag=2, infocriteria="aic", estimator=estimator, errtol=None, basisfunction=basisfunction, ) model.fit(X=xtrain, y=ytrain) yhat = model.predict(X=xvalid, y=yvalid) rrse = rootrelativesquarederror(yvalid, yhat) print(rrse) r = pd.DataFrame( results( model.finalmodel, model.theta, model.err, model.nterms, err_precision=8, dtype='sci' ), columns=['Regressors', 'Parameters', 'ERR']) print(r)

console Regressors Parameters ERR 0 x1(k-2) 0.9000 0.95556574 1 y(k-1) 0.1999 0.04107943 2 x1(k-1)y(k-1) 0.1000 0.00335113 ` python plotresults(y=yvalid, yhat=yhat, n=100, figsize=(14, 3), linewidth=1.5) ``` polynomial

NARX Neural Network

```python from sysidentpy.neuralnetwork import NARXNN from sysidentpy.basisfunction import Polynomial from sysidentpy.utils.plotting import plotresiduescorrelation, plotresults from sysidentpy.residues.residuescorrelation import computeresiduesautocorrelation from sysidentpy.residues.residuescorrelation import computecross_correlation

class NARX(nn.Module): def init(self): super().init() self.lin = nn.Linear(4, 10) self.lin2 = nn.Linear(10, 10) self.lin3 = nn.Linear(10, 1) self.tanh = nn.Tanh()

def forward(self, xb):
    z = self.lin(xb)
    z = self.tanh(z)
    z = self.lin2(z)
    z = self.tanh(z)
    z = self.lin3(z)
    return z

basis_function=Polynomial(degree=1)

narxnet = NARXNN( net=NARX(), ylag=2, xlag=2, basisfunction=basisfunction, modeltype="NARMAX", lossfunc='mseloss', optimizer='Adam', epochs=200, verbose=False, optim_params={'betas': (0.9, 0.999), 'eps': 1e-05} # optional parameters of the optimizer )

narxnet.fit(X=xtrain, y=ytrain) yhat = narxnet.predict(X=xvalid, y=yvalid) plotresults(y=yvalid, yhat=yhat, n=100, figsize=(14, 3), linewidth=1.5) ``` neural

Catboost-narx

```python from catboost import CatBoostRegressor from sysidentpy.generalestimators import NARX from sysidentpy.basisfunction import Polynomial from sysidentpy.utils.plotting import plotresiduescorrelation, plotresults from sysidentpy.residues.residuescorrelation import computeresiduesautocorrelation from sysidentpy.residues.residuescorrelation import computecross_correlation

basis_function=Polynomial(degree=1)

catboostnarx = NARX( baseestimator=CatBoostRegressor( iterations=300, learningrate=0.1, depth=6), xlag=2, ylag=2, basisfunction=basisfunction, fitparams={'verbose': False} )

catboostnarx.fit(X=xtrain, y=ytrain) yhat = catboostnarx.predict(X=xvalid, y=yvalid) plotresults(y=yvalid, yhat=yhat, n=100, figsize=(14, 3), linewidth=1.5) ``` catboost

Catboost without NARX configuration

The following is the Catboost performance without the NARX configuration.

python catboost = CatBoostRegressor( iterations=300, learning_rate=0.1, depth=6 ) catboost.fit(x_train, y_train, verbose=False) plot_results(y=y_valid, yhat=catboost.predict(x_valid), n=100, figsize=(14, 3), linewidth=1.5) catboost

The examples directory has several Jupyter notebooks with tutorials of how to use the package and some specific applications of sysidentpy. Try it out!

Communication

  • Discord server: https://discord.gg/8eGE3PQ

discord

  • Website: http://sysidentpy.org

Citation

DOI

If you use SysIdentPy on your project, please drop me a line.

If you use SysIdentPy on your scientific publication, we would appreciate citations to the following paper:

  • Lacerda et al., (2020). SysIdentPy: A Python package for System Identification using NARMAX models. Journal of Open Source Software, 5(54), 2384, https://doi.org/10.21105/joss.02384

@article{Lacerda2020, doi = {10.21105/joss.02384}, url = {https://doi.org/10.21105/joss.02384}, year = {2020}, publisher = {The Open Journal}, volume = {5}, number = {54}, pages = {2384}, author = {Wilson Rocha Lacerda Junior and Luan Pascoal Costa da Andrade and Samuel Carlos Pessoa Oliveira and Samir Angelo Milani Martins}, title = {SysIdentPy: A Python package for System Identification using NARMAX models}, journal = {Journal of Open Source Software} }

Inspiration

The documentation and structure (even this section) is openly inspired by Scikit-learn, EinsteinPy, and many others as we used (and keep using) them to learn.

Contributors

Sponsors

Special thanks to our sponsors

Monthly Sponsors

statisticallyinsifnificant


Individual Sponsors

Nath Keles


Powered by

PyCharm logo


Owner

  • Name: Wilson Rocha
  • Login: wilsonrljr
  • Kind: user
  • Location: Brazil
  • Company: RD Raia Drogasil

Head of Data Science at RD. Master in Electrical Engineering. Professor. Member of Control and Modelling Group (GCOM)

JOSS Publication

SysIdentPy: A Python package for System Identification using NARMAX models
Published
October 02, 2020
Volume 5, Issue 54, Page 2384
Authors
Wilson Rocha Lacerda ORCID
GCoM - Modeling and Control Group at Federal University of São João del-Rei, Brazil
Luan Pascoal Costa da Andrade
GCoM - Modeling and Control Group at Federal University of São João del-Rei, Brazil
Samuel Carlos Pessoa Oliveira
GCoM - Modeling and Control Group at Federal University of São João del-Rei, Brazil
Samir Angelo Milani Martins
GCoM - Modeling and Control Group at Federal University of São João del-Rei, Brazil, Department of Electrical Engineering at Federal University of São João del-Rei, Brazil
Editor
David P. Sanders ORCID
Tags
System Identification NARMAX Dynamical Systems Model Structure Selection

GitHub Events

Total
  • Create event: 34
  • Release event: 5
  • Issues event: 19
  • Watch event: 68
  • Delete event: 29
  • Issue comment event: 35
  • Push event: 93
  • Pull request review event: 5
  • Pull request event: 70
  • Fork event: 14
Last Year
  • Create event: 34
  • Release event: 5
  • Issues event: 19
  • Watch event: 68
  • Delete event: 29
  • Issue comment event: 35
  • Push event: 93
  • Pull request review event: 5
  • Pull request event: 70
  • Fork event: 14

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 883
  • Total Committers: 19
  • Avg Commits per committer: 46.474
  • Development Distribution Score (DDS): 0.07
Past Year
  • Commits: 223
  • Committers: 7
  • Avg Commits per committer: 31.857
  • Development Distribution Score (DDS): 0.081
Top Committers
Name Email Commits
Wilson Rocha w****r@o****m 821
Samuel Oliveira r****2@g****m 19
Marcos Oliveira m****4@g****m 11
LuanPascoal 4****l 8
Samuel Oliveira s****a@g****m 4
unknown m****s@g****m 3
Lennart Werner m****l@l****e 2
Matheus Teixeira m****4@g****m 2
dj-gauthier 4****r 2
lsamuel41196 5****6 2
Armando Barbosa a****4@g****m 1
Caio Mizerkowski c****i@g****m 1
David P. Sanders d****s@g****m 1
Gabriel 7****r 1
GabrielBuenoLeandro g****0@g****m 1
Goutam 1****l 1
Suyash Gaikwad s****d@S****l 1
Arturo Melendez a****z@o****m 1
Natália Keles 6****s 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 35
  • Total pull requests: 120
  • Average time to close issues: 10 months
  • Average time to close pull requests: 8 days
  • Total issue authors: 21
  • Total pull request authors: 15
  • Average comments per issue: 2.51
  • Average comments per pull request: 0.4
  • Merged pull requests: 104
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 10
  • Pull requests: 92
  • Average time to close issues: 17 days
  • Average time to close pull requests: about 11 hours
  • Issue authors: 8
  • Pull request authors: 6
  • Average comments per issue: 1.9
  • Average comments per pull request: 0.17
  • Merged pull requests: 82
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • wilsonrljr (13)
  • himanshupant24 (2)
  • onguntoglu (2)
  • AntoineDubois (1)
  • jtylka (1)
  • helonayala (1)
  • lukagrden (1)
  • lucas-mior (1)
  • intern-hue (1)
  • nema69 (1)
  • tzhu-ece (1)
  • DJIDM (1)
  • Lalith-Sagar-Devagudi (1)
  • wangshanze (1)
  • uqdlt (1)
Pull Request Authors
  • wilsonrljr (91)
  • oliveira-mark (8)
  • lsamuel41196 (2)
  • goutam-kul (2)
  • SHRISHTISHUKLA-0 (2)
  • nataliakeles (2)
  • hyunwooOpa (2)
  • LeWerner42 (2)
  • uqdlt (2)
  • GabrielBuenoLeandro (2)
  • poglesbyg (1)
  • Suyash-Gaikwad9 (1)
  • dj-gauthier (1)
  • gamcorn (1)
  • mtsousa (1)
Top Labels
Issue Labels
Enhancement (10) team effort (9) Documentation (5) bug (3) Basis Function (2) good first issue (2) needs research (1) Model Structure Selection (1) Metrics (1) question (1)
Pull Request Labels
Basis Function (3) Documentation (2) Enhancement (2) Utils (1)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 787 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 1
  • Total versions: 24
  • Total maintainers: 4
pypi.org: sysidentpy

A Python Package For System Identification Using NARMAX Models

  • Documentation: https://sysidentpy.readthedocs.io/
  • License: BSD 3-Clause License Copyright (c) 2019, Wilson Rocha; Luan Pascoal; Samuel Oliveira; Samir Martins All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  • Latest release: 0.6.0
    published 11 months ago
  • Versions: 24
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 787 Last month
Rankings
Downloads: 9.8%
Dependent packages count: 10.1%
Average: 13.8%
Dependent repos count: 21.6%
Last synced: 6 months ago

Dependencies

requirements.txt pypi
  • matplotlib *
  • numpy *
  • scipy *
  • torch >=1.7.1
.github/workflows/python-package.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
pyproject.toml pypi
  • matplotlib >=3.3.2
  • numpy >=1.19.2
  • scipy >=1.7.0