ConfusionMatrix
Introduction
ConfusionMatrix
is a widget that display a given confusion matrix with color-coded visualization for better interpretation. It also shows row and column totals.
ConfusionMatrix
allows users to customize the axis labels, detect cell clicking events, and control it from Python code.
Function signature
prepare data for widget
or
Parameters
Parameters | Type | Description |
---|---|---|
|
| Matrix table data |
|
| List of columns names |
|
| Columns label |
|
| Rows label |
|
| ID of the widget |
data
Matrix table data in different formats:
Pandas Dataframe
Python dict with structure
x_label
Columns label.
type: str
default value: "Predicted Values"
y_label
Rows label.
type: str
default value: "Actual Values"
widget_id
ID of the widget.
type: str
default value: None
Methods and attributes
Attributes and Methods | Description |
---|---|
| Get or set table |
| Convert table data to json. |
| Convert table data to pandas dataframe. |
| Read and set table data from json. |
| Read and set table data from pandas dataframe. |
| Get selected table cell info. |
| Decodator function is handled when table cell is pressed. |
Mini App Example
You can find this example in our Github repository:
ui-widgets-demos/charts and plots/004_confusion_matrix/src/main.py
Import libraries
Init API client
First, we load environment variables with credentials and init API for communicating with Supervisely Instance:
Prepare function that creates example pandas table
Create data for table.
Initialize ConfusionMatrix
widget
ConfusionMatrix
widgetCreate app layout
Prepare a layout for app using Card
widget with the content
parameter and place widget that we've just created in the Container
widget.
Create app using layout
Create an app object with layout parameter.
Last updated