- Setup Project
- UI Creation
- App state and bindings
- Python implementation
- Troubleshooting
Project Setup
To create our project, we will use the following commands:requirements.txt and add the following line:

UI Creation
By default, Framework creates a simple application with a counter. To keep things easy, let’s remove the contents from columns to make space for our new application. If you’re unsure where to click to select a specific component on the screen, you can always use theComponent Tree on the bottom left of the screen. The app should look something like this when you finish.

Width (factor) in the left column to 0.5.

1/3 of the screen. Proportions are calculated relative to each other. Each Column, by default, has the value of this factor set to 1. So, when we set the left column to 0.5 and the right to 1, we will get a relation between column sizes of 1:2.

- To the right column, add a Plotly Graph.
- To the left:
- 3 x Slider Input
- Dropdown Input
- Button.
- To the free space in the header, let’s place a Message component.

| Property | Value (Slider 1) | Value (Slider 2) | Value (Slider 3) |
|---|---|---|---|
| Label | Number of groups | Number of points | Cluster deviation |
| Minimum value | 2 | 50 | 0 |
| Maximum value | 10 | 1000 | 10 |
| Step size | 1 | 1 | 0.1 |
| Property | Value |
|---|---|
| Label | Type |
| Options | set JSON and paste: |
{"ovr": "One vs Rest", "multinomial": "Multinomial"} |
| Property | Value |
|---|---|
| Text | Regenerate |
App State and Bindings
It is time to create the application’s initial state. Let’s open the code editor. In this tutorial, we will be using the built-in code editor, which can be found by clicking on the ‘Code’ button at the top of the screen. However, if you prefer using your favourite editor, you can simply edit themain.py file, and the app will auto-refresh every time the file is changed.

Save and run, the header of our application will immediately change to “Logistic regression visualiser”. This is because the Header has in its text property the value @{my_app.title}, which is a template syntax that uses a value from the state.
The rest of the keys and values from the initial_state are names and initial values for components that will be used for communication between the app UI and the back-end. Assigning those keys to components is called binding, and it is done by clicking on each component and filling property “State element” in the “Binding” menu. Let’s use these bindings for our 3 Slider Input components:
| Property | Value (Slider 1) | Value (Slider 2) | Value (Slider 3) |
|---|---|---|---|
| State element | number_of_groups | number_of_points | cluster_std |
| Property | Value |
|---|---|
| State element | multi_class |
Component Tree to click the element and open the Properties menu.
Message component doesen’t have bindings but we still can use template syntax to use data from the state inside of a Message. Additionaly we are able to use this data to control the visibility of the component.
| Property | Value |
|---|---|
| Message | @{message} |
| Visibility | custom |
| Visibility value | message |
| Property | Value |
|---|---|
| Graph specification | @{figure} |
Python implementation
Let’s create a function that will update our application based on inputs and call it immediately.scikit-learn library.
make_blobs will generate number_of_points points on a 2D space that have a cluster deviation set to cluster_std and the number of groups defined by number_of_groups. After that, we generate a LogisticRegression, and we take parameters we need. For better knowledge about the process, let’s display the training score as a message.
plotly.graph_objects to have full control over what will be included in our plot.
wf-number-change in all slider inputs to update, which is the name of our function in the Python code. Notice that _line is not visible there because it’s private to the back-end. If we would change its name to line, then it would be visible on this list.
Set also event handler for dropdown input wf-option-change and wf-click in the button, also to update.
And done! You can have fun with your new application. Feel free to modify and play with other options.
Final code for the application should look something like this:
Troubleshooting
Errors
When your code has an error, you will be notified with a notification in the app, and also in the console, you can find useful logs.Debugging
To check some intermediate values in your Python code, you can just useprint() function. All logs will be available in the terminal.