sdtDBNsGUI

Graphical User Interface (GUI) for the sdtDBN program

View project on GitHub

Webpage description

This webpage explains how to use the Graphical User Interface (GUI) of the sdtDBN program.

sdtDBN program

sdtDBN is a program, implemented in Java, developed to learn Dynamic Bayesian Networks (DBNs) with both static and dynamic features/attributes, also allowing a user to make inference on the learned DBNs and to make restrictions in the structure of the learned networks. All background related to sdtDBNs can be checked in the sdtDBNs’ webpage, available at https://ttlion.github.io/sdtDBN/. The GUI presented in this webpage is an interface for a user to be able to control the sdtDBN program’s capabilities in a graphical way.

Current releases and external libraries

Current releases

The GUI was developed using Python, being all source files available here, with the respective GitHub repository available here.

For a user to be able to run the program without having to resort to the Python programming language, there are available executable standalone versions of the program, for Windows and for Linux, both in version v0.0.1:

These executable versions were created, from the Python source code, using PyInstaller.

External libraries

To generate images for the sdtDBNs, the GUI uses the DOT language. Therefore, if the user wants to employ the GUI to create graphical representations of the learned sdtDBNs (more details here), Graphviz must be installed in the proper Operating System. Check here for information about how to install Graphviz.

The program, written in Python, uses several Python libraries/modules (which the user only needs to install if working with the source code, instead of working with the provided standalone versions). An overview of the used libraries/modules is given next:

  • tkinter, for generating the Graphical User Interface, with all its capabilities;
  • csv, for parsing CSV files;
  • sys, for using some specific methods of the Python interpreter;
  • os, for using some capabilities of the Operating System directly from the Python program;
  • subprocess, for running command line arguments using the Python program;
  • webbrowser, for opening webpages from the GUI;
  • re, for making operations using regular expressions.

How to use the sdtDBN GUI program?

The sdtDBNs GUI is composed by 7 tabs, each with its specific function in order to use the capabilities of the sdtDBN program. The general workflow of the sdtDBNs GUI using the developed tabs is the following:

  1. To learn an sdtDBN, the user can resort to either the first tab or the second tab;
    • The first tab should be used if the user wants to learn an sdtDBN from input data/observations;
    • The second tab should be used if the user wants to retrieve an sdtDBN object previously learned and stored in a file.
  2. After learning an sdtDBN, the user might desire to get a graphical representation of the sdtDBN, for which the third tab should be used;

  3. To perform inference, there must be given some observations of the subjects/ids on which inference should be made, which can be done in the fourth tab;

  4. After learning an sdtDBN and loading the observations for making inference, there are three inference modes a user can choose, each in its specific tab:

    1. If the user wants to estimate the probability distribution of a specific attribute in a particular timestep, given the data of a certain subject/id, the fifth tab should be used;

    2. If the user wants to, given the data of a specific subject/id, predict the progression of either all attributes or a particular attribute until a certain timestep, the sixth tab can be used;

    3. If the user wants to make predictions for several subjects/ids, the seventh tab is the correct one.

Given the general workflow described, the usage of each tab is described next. Throughout the explanations, several input files are used, which can be downloaded by clicking on their names or at the top of the webpage, where there is provided a zip file with all input files used.

First tab: learning an sdtDBN from user data

When opening the first tab, the GUI shows the following display:

Tab 1 of GUI
Initial display of tab 1

To learn an sdtDBN using this first tab, all learning inputs and parameters of the sdtDBN program should be specified:

  • The CSV files with observations must be given (if only given dynamic observations, the program will learn a tDBN, without static attributes);
  • If the user wants to make restrictions in the sdtDBN, the desired restrictions should be introduced in CSV files and put in the proper field of the GUI (among the six options available at the bottom of the first tab);
  • The remaining parameters can be tuned according to the user’s needs.

For illustration, providing the following parameters:

  • File with dynamic observations: example1_dynamic.csv
  • File with static observations: example1_static.csv
  • Markov lag: 1
  • Max parents from past: 1
  • Max static parents: 1
  • Scoring Function: Log-Likelihood (LL)
  • Stationary sdtDBN?: yes
  • File to save the learned sdtDBN: exampleFile.txt
  • Files with restrictions: all 6 fields left without file, not using restrictions in the network learned

The output would be:

Tab 1 of GUI - results
Display of tab 1 after learning an sdtDBN

The obtained sdtDBN shown in the previous image is the same one as in Example 1 of the sdtDBN webpage, as all the learning parameters are the same.

The object with the learned sdtDBN is stored in a file (named exampleFile.txt in the example of the previous image). This file is created in the same directory of the sdtDBN GUI program and can be used to retrieve the learned sdtDBN afterwards, using the second tab.

:warning: In this illustration of the first tab, the sdtDBN was learned without any restrictions, being also this unrestricted sdtDBN the one used throughout the explanations of the next tabs. For an example on how to add restrictions when learning an sdtDBN, check Example 6 of the sdtDBN webpage, where all types of restrictions are specified and example files are given (to use them in the GUI, it is only needed to insert each file in the proper input of the first tab). All files used in Example 6 of the sdtDBN webpage are also provided in the zip file at the top of the webpage (the zip file with the several input files used in the examples of this webpage). :warning:

Second tab: retrieving an sdtDBN object stored in a file

When opening the second tab, the GUI shows the following display:

Tab 2 of GUI
Initial display of tab 2

Having an sdtDBN object stored in a file (after, for example, learning an sdtDBN from data using the first tab), the object with the learned sdtDBN can be loaded into the GUI program using this second tab.

Therefore, providing the following parameter:

  • File with sdtDBN object: exampleFile.txt (see first tab)

The output would be:

Tab 2 of GUI - results
Display of tab 2 after retrieving an sdtDBN object stored in a file

This output presents the same sdtDBN learned in the first tab.

Third tab: getting the graphical representation of a learned sdtDBN

When opening the third tab without having learned an sdtDBN either from the first tab or the second tab, the GUI shows the following display:

Tab 3 of GUI
Initial display of tab 3

:warning::warning::warning: As the field sdtDBN being used states by displaying No file yet selected, an sdtDBN must be learned (using the first or second tabs) before using this tab. :warning::warning::warning:

After having learned an sdtDBN, a graphical representation can be generated in this third tab.

Therefore, using the following parameters:

  • sdtDBN being used: exampleFile.txt (inserted in first tab)
  • Image filename: imgNameExample

The output would be:

Tab 3 of GUI - results
Display of tab 3 after generating image

Besides being presented directly in the GUI (see previous image), the graphical representation of the learned sdtDBN is also stored in a PNG file (named imgNameExample.png in the example of the previous image). This file is created in the same directory of the sdtDBN GUI program. As the sdtDBN is the one from the first tab’s explanation, the graphical representation of the sdtDBN is the same as the one obtained in Example 1 of the sdtDBN webpage.

Fourth tab: inserting the observations that will be used to make inference on a learned sdtDBN

When opening the fourth tab without having learned an sdtDBN either from the first tab or the second tab, the GUI shows the following display:

Tab 4 of GUI
Initial display of tab 4

:warning::warning::warning: As the field sdtDBN being used states by displaying No file yet selected, an sdtDBN must be learned (using the first or second tabs) before using this tab. :warning::warning::warning:

After learning an sdtDBN, the user must come to this tab to introduce the observations that should be used when making inference.

For example, inserting the following parameters:

The output would be:

Tab 4 of GUI - results
Display of tab 4 after submitting the CSV files with the useful observations for making inference

In the example provided in the previous image, the introduced files were the ones used in the sdtDBN webpage, so that the explanations of the remaining tabs can relate to the examples presented in the sdtDBN webpage.

As stated in the explanation of the first tab, the CSV input files with dynamic and static observations must be in the format explained in the sdtDBN webpage.

Fifth tab: predicting the distribution of a selected attribute in a certain timestep for a defined id

When opening the fifth tab without having learned an sdtDBN (either from the first tab or the second tab), and without having specified any observations to be used for inference (using the fourth tab) the GUI shows the following display:

Tab 5 of GUI
Initial display of tab 5

:warning::warning::warning: As the field sdtDBN being used states by displaying No file yet selected, an sdtDBN must be learned (using the first or second tabs) before using this tab. :warning::warning::warning:

:warning::warning::warning: As the field Desired id states by displaying Inference observations not given!, the observations to be used when making inference should be inserted (using the fourth tab) before using this tab. :warning::warning::warning:

After properly learning an sdtDBN (using the first or second tabs) and inserting the useful observations for inference (using the fourth tab), a user can select the several options of this tab to estimate the probability distribution of an attribute in a certain timestep, for a selected id.

For example, introducing the following arguments:

  • sdtDBN being used: exampleFile.txt (inserted in first tab)
  • Desired id: 1
  • Desired attribute: a
  • Desired timestep: 3

And having inserted the observations for inference detailed in the explanation of the fourth tab, the output would be:

Tab 5 of GUI - results
Display of tab 5 after specifying all parameters needed and making inference

This output is the same as the one obtained when the distributions are estimated in Example 2 of the sdtDBN webpage.

Sixth tab: predicting the progression of one or all attributes, for a defined id

When opening the sixth tab without having learned an sdtDBN (either from the first tab or the second tab), and without having specified any observations to be used for inference (using the fourth tab) the GUI shows the following display:

Tab 6 of GUI
Initial display of tab 6

:warning::warning::warning: As the field sdtDBN being used states by displaying No file yet selected, an sdtDBN must be learned (using the first or second tabs) before using this tab. :warning::warning::warning:

:warning::warning::warning: As the field Desired id states by displaying Inference observations not given!, the observations to be used when making inference should be inserted (using the fourth tab) before using this tab. :warning::warning::warning:

After properly learning an sdtDBN (using the first or second tabs) and inserting the useful observations for inference (using the fourth tab), the several options of this tab allow a user to estimate a trajectory, until a certain timestep, of either a specific attribute or all attributes, given the data of a defined subject/id.

For example, introducing the following arguments:

  • sdtDBN being used: exampleFile.txt (inserted in first tab)
  • Desired id: 3
  • Desired attribute: all
  • Maximum timestep: 5
  • Desired estimation mode: Most Probable

And having inserted the observations for inference detailed in the explanation of the fourth tab, the output would be:

Tab 6 of GUI - results
Display of tab 6 after specifying all parameters needed and making inference

The trajectory obtained in the previous image is the same as the one obtained in Example 3 of the sdtDBN webpage for subject 3, as all parameters specified are the same.

Seventh tab: making predictions for several ids

When opening the seventh tab without having learned an sdtDBN (either from the first tab or the second tab), and without having specified any observations to be used for inference (using the fourth tab) the GUI shows one of the two displays presented next, according to the selected mode of this seventh tab.

In the Attribute inference mode, the initial display is the following:

Tab 7 of GUI - att inf
Initial display of tab 7 in Attribute inference mode

In the Progression until timestep mode, the initial display is the following:

Tab 7 of GUI - prog until timestep
Initial display of tab 7 in Progression until timestep mode

:warning::warning::warning: As the field sdtDBN being used states by displaying No file yet selected, an sdtDBN must be learned (using the first or second tabs) before using this tab. :warning::warning::warning:

:warning::warning::warning: As this tab concerns inference capabilities of the sdtDBN, the observations to be used when making inference should be inserted (using the fourth tab) before using this tab. :warning::warning::warning:

As already stated, this seventh tab has two modes: Attribute inference and Progression until timestep. Each mode’s functioning is detailed next.

Seventh tab — Attribute inference mode

In the Attribute inference mode (see the first image of this tab’s explanation), besides choosing among the available estimation modes (see Example 2 of the sdtDBN webpage for details on the three available modes), the user must introduce a file with the variables in which inference should be made. This file must be a CSV file with the format described in the proper section of the sdtDBN webpage. The program will provide, for all subjects/ids in the observation files given in the fourth tab, estimations for the attributes selected in the previously mentioned CSV file with the variables in which inference should be made.

For illustration, introducing the following arguments:

  • sdtDBN being used: exampleFile.txt (inserted in first tab)
  • Desired mode: Attribute inference
  • Desired estimation mode: Distribution
  • File with vars to inference: example2_infVars.csv (same file used in the sdtDBN webpage)
  • Output filename: exampleOut.csv

And having inserted the observations for inference detailed in the explanation of the fourth tab, the output would be:

Tab 7 of GUI - att inf - after
Display of tab 7 in Attribute inference mode, after making inference

The inference output presented in the previous image is the same output obtained when the distributions are estimated in Example 2 of the sdtDBN webpage.

When making inference as shown in the previous image, the inference output is also saved in a file with the name provided by the user in the GUI (exampleOut.csv in the example of the previous image). This file is created in the same directory of the sdtDBN GUI program.

Seventh tab — Progression until timestep mode

In the Progression until timestep mode (see the second image of this tab’s explanation), the user should define the desired estimation mode and the maximum timestep. The program will determine, for all subjects/ids in the observation files given in the fourth tab, an estimated trajectory of all attributes until the defined maximum timestep.

For instance, introducing the following arguments:

  • sdtDBN being used: exampleFile.txt (inserted in first tab)
  • Desired mode: Progression until timestep
  • Desired estimation mode: Most Probable
  • Maximum timestep: 5
  • Output filename: exampleOut.csv

And having inserted the observations for inference detailed in the explanation of the fourth tab, the output would be:

Tab 7 of GUI - prog until timestep - after
Display of tab 7 in Progression until timestep mode, after making inference

The inference output presented in the previous image is the same output given in Example 3 of the sdtDBN webpage.

The inference output of the example of the previous image is also saved in a file with the name provided by the user in the GUI (exampleOut.csv in the example of the previous image). This file is created in the same directory of the sdtDBN GUI program.