Skip to main content

ModelFlow

A Python toolkit to manage models

The easy way to start is here Binder.

This will start ModelFlow as an online Jupyter notebook. Select one of the notebooks (files with the extension .ipynb). Some of the notebooks are ModelFlow related. Other implement different model

  • FRBUS will start the FRB/US model from the Federal reserve board.
  • Q-JEM will start the Quarterly Japanese Economic Model from Bank of Japan
  • ADAM will start the Anual Danish Aggregate Model for the Danish Statistical agency.
  • Solow will implement a simple textybook Solow model.

You can also look at the python files of the system. Located at the modelflow/ folder

Alternative look at the getting started section later in this file. It explains how to run ModelFlow localy.

The Pandas library is a great library to handle all kinds of datamanipulation and transformations.

However when it comes to models which contains lags or models which requires solving simultanous equations, Pandas is not quite helpful.

ModelFlow extends Pandas to handle a range of such models. And they can be large.

It requires you to specify the model specified as equations (the business logic) and place the data in a Pandas DataFrame. ModelFlow allows the model to meet the data and return the result as a new DataFrame.

A number of analytical tools for model and result analytic helps to understand the model and its results.

The user can extend and modify the tools to her or his needs.

Onboarding models and combining models from different sources. Creating a Macro prudential model often entails recycling several models specified in different ways: Excel, Latex, Dynare, Python or other languages. Python's ecosystem makes it possible to transform many different models into ModelFlow models or to wrap them into functions which can be called from ModelFlow models.

Models can be specified in a high level Business logic language (a Domain Specific language). This allows the formulation of a model in a concise and expressive language which is close to the economic of the model. The user can concentrate on the economic or financial content - not the coding of the solution. The code for solving the model is generated by the tool. Then you can solve the simultaneous (or non-simultaneous model) in an efficient way.

Introduction

ModelFlow is written in Python. Python comes "batteries included" and is the basis of a very rich ecosystem, which consists of a wide array of libraries. ModelFlow is just another library. It supplements the existing libraries regarding modeling language and solving and allows the use of Python as a model management framework.

Data handling and wrangling is done in the Pandas library. This library is the Swiss army knife of data science in Python. It can import and export data to most systems and it is very powerful in manipulating and transforming data. The core element of Pandas is the Dataframe. A Dataframe is a two-dimensional tabular data structure. Each column consists of cells of the same type -- it can be a number, a string, a matrix or another Python data object.This includes matrices and other dataframes. Each row is indexed. The index can basically be any type of variable including dates, which is especially relevant for economic and financial models.

ModelFlow gives the user tools for more than solving models. This includes:

  • Visualization and comparison of results

  • Integration of models from different sources

  • Analyze the logical structure of a model. By applying graph theory, ModelFlow can find data lineage, find a suitable calculating sequence and trace causes of changes through the calculations.

  • Inverting the model to calculating the necessary instruments to achieve a desired target.

  • Calculating the attributions from input to the results of a model.

  • Calculating the attribution from input to the result of each formula.

  • Finding and calculating partial derivatives of formulas

  • Integrating user defined python functions in the Business logic language (like optimization, calculating risk weights or to make a matrices consistent with the RAS algorithm )

  • Wrap matlab models so they can be used in the Business logic language.

  • Speed up solving using "Just in time compilation"

  • Analyze the model structure through tools from graph theory

  • Handle large models. 1,000,000 formulas is not a problem.

  • Integrate model management in Jupyter notebooks for agile and user friendly model use

The core code of ModelFlow is small and documented. Thus it can easily be modified and expanded to the specific need of the user. ModelFlow is a toolset. It can handle models, which conform to the tools.

If you need a feature or have a model which can't be handled in ModelFlow, you are encouraged to improve ModelFlow. Please share the improvement, other users may have the same need, or can be inspired by your work.

Also bear in mind that ModelFlow is experimental. It is provided ”as is”, without any representation or warranty of any kind either express or implied.

Getting started

You need Python 3.7+ with asssociated libraries. The easy way is to install Anaconda Python is to download the distribution from https://www.anaconda.com/distribution

Now you can install ModelFlow by running a command window from the Anaconda prompt and execute theese commands

conda install modelflow -c ibh -c defaults -c conda-forge

You will find the anaconda prompt by searching "anaconda" in the start menu search field

Try out one of the workbooks. to do this you:

click on the Adaconda prompth in the Anaconda folder
cd <The location you have downloaded the workbooks>
jupyter notebook

Release files for modelflowib 2.77

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for modelflowib 2.77
File Size Uploaded
modelflowib-2.77.tar.gz 442.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for modelflowib 2.77
File Interpreter ABI Platform
modelflowib-2.77-py3-none-any.whl Python 3 none any Details

Total release size: 904.3 kB

Release files / modelflowib-2.77.tar.gz

Download URL modelflowib-2.77.tar.gz
Size 442.9 kB
Tags Source
SHA-256 checksum
How to use checksums
73284692743c6873082fe31ff324334ac39ce803242c11b0eac48a1a7437bd59
BLAKE2b-256 checksum
How to use checksums
d3e2c700e76ba6f3b990b57ab60361b09fb872f17ad2d34249c13e17130aea09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Release files / modelflowib-2.77-py3-none-any.whl

Download URL modelflowib-2.77-py3-none-any.whl
Size 461.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
075c341add50aa09b94aea3d371f774fdde7e102bbbb63f8fe6baecb44b014cd
BLAKE2b-256 checksum
How to use checksums
7952a2eb3c4d367195bc8a780ac5a2ad939185bd86848837557f0c2d28927421
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.13

Release history Release notifications | RSS feed

2.78

2 release files

This release

2.77 This release

2 release files

2.76

2 release files

2.75

2 release files

2.74

2 release files

2.73

2 release files

2.72

2 release files

2.71

2 release files

2.70

2 release files

2.69

2 release files

2.68

2 release files

2.67

2 release files

2.65

2 release files

2.64

2 release files

2.63

2 release files

2.62

2 release files

2.61

2 release files

2.60

2 release files

2.59

2 release files

2.58

2 release files

2.57

2 release files

2.56

2 release files

2.55

2 release files

2.54

2 release files

2.53

2 release files

2.52

2 release files

2.51

2 release files

2.50

1 release file

2.49

1 release file

2.34

1 release file

2.27

1 release file

2.14

1 release file

2.13

1 release file

2.11

1 release file

2.10

1 release file

2.7

1 release file

2.5

1 release file

2.4

1 release file

1.56

1 release file

1.55

1 release file

1.54

1 release file

1.53

1 release file

1.52

1 release file

1.51

1 release file

1.50

1 release file

1.49

1 release file

1.48

1 release file

1.47

1 release file

1.46

1 release file

1.45

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page