Example notebooks

Here are several examples of how you can analyze and model data using the open model hub. All examples are also available as Jupyter notebooks from our GitHub repository and can run if all requirements are installed.

To get started you will first have to instantiate the open model hub and create a Bach DataFrame with Objectiv data. The open model hub uses this DataFrame for its models. For a general introduction to Bach DataFrames, see the Bach docs or some basic examples to get started here.

Getting started with Objectiv

Here we show how to install and instantiate the model hub. The open model hub is installed with:

pip install objectiv-modelhub

Now we can import and instantiate the model hub and create a Bach DataFrame with Objectiv data. This DataFrame is used to analyze data collected with Objectiv’s Tracker. The DataFrame points to the data in the SQL database and all operations are done on this object. A start date and an end date can optionally be passed to limit the underlying data that is queried. The time_aggregation parameter determines the default formatting of the timestamp of events. This is useful for grouping to different time aggregations, i.e. monthly or daily.

In the example we assume that the data collected with Objectiv’s tracker is stored in a table called ‘example’ in a database that can be accessed with db_url.

from modelhub import ModelHub
# instantiate the model hub
modelhub = ModelHub(time_aggregation='YYYY-MM-DD')
# get the Bach DataFrame with Objectiv data
df = modelhub.get_objectiv_dataframe(db_url='postgresql://objectiv:@localhost:5432/objectiv',

Your DataFrame is instantiated! We start with showing the first couple of rows from the data set.


Take a look at one of the example notebooks below to see how you can analyze your data. Basic Bach introduction examples are here.