Jupyter Visualization
Jupyter notebook can be used to visualize the logged data. For this purpose, several Jupyter widgets and plotting functions based on plotly and tabulate are provided.
All widgets and functions can be accessed under the module: exputils.gui.jupyter
Please note that the current widgets only work with Jupyter Notebook <= 6.5 and are also not compatible with Jupyter Lab.
General Widgets
ExperimentDataLoaderWidget
Bases: BaseWidget
, VBox
Jupyter widget for loading experiment data which can then be used for analysis and visualization.
The widget allows to select which experiments and datasources are loaded.
The widget provides basically a GUI for the load_experiment_data function.
It is also possible to define callback functions that allow to compute statistics of the
loaded data or alter the data.
After the user loaded the data through the widget it is available via its experiment_data
property.
GUI of the widget:
Functionality:
- Update Descriptions: Load the descriptions of new experiments. This can be used to update the table after more experiments have been performed.
- Reset Descriptions: Resets the descriptions of experiments in the table to their default if they had been changed by the user.
- Up Button: Moves the selected experiments up in the order.
- Down Button: Moves the selected experiments down in the order.
- Sort by Experiment ID: Resorts the experiments according to their ID.
- Load Data: Loads the data of all selected experiments. It is then available via the
experiment_data
property. - Empty Data: Empties the loaded data to free memory.
Example
Execute the following code in a Jupyter notebook located in the experiment campaign directory under a subdirectory, such as ./analysis
.
Source code in exputils/gui/jupyter/experiment_data_loader_widget.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 |
|
ExperimentDataPlotSelectionWidget
Bases: ExperimentDataSelectionWidget
Jupyter widget for plotting experiment data and creating Jupyter cells for dedicated plotting.
The widget allows to select the datasource that should be plotted and the plotting function. It also allows to select which experiments should be plotted and to create dedicated Jupyter cells to plot specific datasources.
GUI of the widget:
Functionality:
- Data Sources: Allows to define the datasource or datasources that should be plotted.
The datasource names correspond to the filenames under the data folder of repetitions and
correspond to the names that were used by the logging functions.
A comma-seperated list of datasources can be provided for table plots (tabulate_meanstd).
It is also possible to extract single elements from data arrays using bracket operation after the name.
For example
loss[-1]
will access the final loss value. - Experiments: Selection of experiments from which data was loaded that should be plotted.
- Repetitions: Selection of repetitions from which data was loaded that should be plotted.
- Plot Function: Plotting function that should be used. See the Plotting Functions section for a list of exisiting plotting functions.
- Plot Configuration: Configuration of the plotting function. See the Plotting Functions section for details.
- Plot Data: Plots the data below the widget.
- Code Production: Creates a new Jupyter notebook cell below the current one that contains the code to plot the data again with all the configuration that was set in the GUI. The code also allows to change the configuration.
Example
Execute the following code in a Jupyter notebook located in the experiment campaign directory under a subdirectory, such as ./analysis
.
This code should be executed after data has been loaded, for example via the ExperimentDataLoaderWidget.
Source code in exputils/gui/jupyter/experiment_data_plot_selection_widget.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 |
|
Plotting Functions
plotly_meanstd_scatter
Interactive line plot that shows the mean and std over all repetitions of each experiment or to show the individual repetitions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
list
|
Data to plot. Should be in the following forms:
|
None
|
config
|
dict
|
Dictionary with configuration of plot. |
None
|
Configuration:
layout
(dict
): See Plotly layout for all possible options.xaxis
(dict
):title
(str
): Title of the x-axis.range
(tuple
): Tuple with min and max values of x-axis. Default is[None, None]
.
yaxis
(dict
)title
(str
): Title of the y-axis.range
(tuple
): Tuple with min and max values of y-axis. Default is[None, None]
.
moving_average
(dict
):n
(int
): Number of elements (over the x-axis) over which a moving average should be computed. Default is1
.
data_filter
(dict
):every_nth_step
(int
,dict
): Either an integer with the number of steps or a dictionary. In case of a dictionary:step
(int
): Number of steps between taken values. Default isNone
.include_final_step
(bool
): Should the final step (the final value) also be included even if outside the stepping. Default isFalse
.
Returns:
Name | Type | Description |
---|---|---|
fig |
figure
|
Plotly figure object that can be displayed using |
The plot is based on Plotly scatter.
Source code in exputils/gui/jupyter/plotly_meanstd_scatter.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 |
|
plotly_box
Interactive box plot that shows several statistics such as the mean, std and range of scalars over all repetitions of each experiment.
Parameters: data (list): Data to plot. config (dict): Dictionary with configuration of plot.
Configuration:
layout
(dict
): See Plotly layout for all possible options.xaxis
(dict
):title
(str
): Title of the x-axis.range
(tuple
): Tuple with min and max values of x-axis. Default is[None, None]
.
yaxis
(dict
)title
(str
): Title of the y-axis.range
(tuple
): Tuple with min and max values of y-axis. Default is[None, None]
.
Returns:
fig (figure): Plotly figure object that can be displayed using display(fig)
.
The plot is based on Plotly box plots.
Source code in exputils/gui/jupyter/plotly_box.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
|
plotly_meanstd_bar
Interactive bar plot that shows the mean and std of scalars over all repetitions of each experiment.
Parameters: data (list): Data to plot. config (dict): Dictionary with configuration of plot.
Configuration:
layout
(dict
): See Plotly layout for all possible options.xaxis
(dict
):title
(str
): Title of the x-axis.range
(tuple
): Tuple with min and max values of x-axis. Default is[None, None]
.
yaxis
(dict
)title
(str
): Title of the y-axis.range
(tuple
): Tuple with min and max values of y-axis. Default is[None, None]
.
Returns:
fig (figure): Plotly figure object that can be displayed using display(fig)
.
The plot is based on Plotly bar charts.
Source code in exputils/gui/jupyter/plotly_meanstd_bar.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
|
tabulate_meanstd
Table that shows the mean and std of scalars over all repetitions of each experiment. Can be used to display several datasources.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
list
|
Data to plot. |
None
|
config
|
dict
|
Dictionary with configuration of plot. |
None
|
Configuration:
-
primary_content_function
(function
): Handle to function that computes the first value of a cell. Function format:func(data: nparray) -> scalar
. Default isnumpy.nanmean
. -
secondary_content_function
(function
): Handle to function that computes the first value of a cell. Function format:func(data: nparray) -> scalar
. Default isnumpy.nanstd
. -
tabulate
(dict
): Parameters for the tabulate function that plots the table. See tabulate for all possible parameters. Some important ones:tablefmt
(str
): Format of the table such as'html'
,'latex'
, or'simple'
. Default is'html'
.-
numalign
(str
): Alignment of numbers in the table ('right'
,'center'
, or'left'
). Default is'right'
. -
cell_format
(str
): Format of the cell content. The format can take up to 2 numbers which are by default the mean and the std. Default is'{:.3f} ({:.3f})'
.
-
flip_rows_and_cols
(bool
): Should the content of rows and columns be flipped. Default isFalse
. -
top_left_cell_content
(str
): Content of the top left cell which can be used as a label for the table. Default is''
.
Returns:
Name | Type | Description |
---|---|---|
fig |
figure
|
Plotly figure object that can be displayed using |
The plot is based on tabulate.
Source code in exputils/gui/jupyter/tabulate_meanstd.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
|
tabulate_pairwise
Plots a pairwise comparison between data from experiments based on a pairwise function d = f(exp_a, exp_b). By default it performs a Mann-WhitneyU P-Value test to identify significant differences between experiments.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
list
|
Data to plot. |
None
|
config
|
dict
|
Dictionary with configuration of plot. |
None
|
Configuration:
-
pairwise_function
(function
): Handle to function that computes the difference between the data of two experiments. Function format:func(exp1_data: nparray, exp2_data: nparray) -> scalar
. Default iseu.misc.mannwhitneyu_pvalue
. -
pairwise_mode
(str
): Which pairs of experiments are compared? Possible values are'full'
,'full_not_identity'
,'upper_triangle'
,'upper_triangle_not_identiy'
,'lower_triangle'
,'lower_triangle_not_identiy'
. Default is'full'
. -
tabulate
(dict
): Parameters for the tabulate function that plots the table. See tabulate for all possible parameters. Some important ones:tablefmt
(str
): Format of the table such as'html'
,'latex'
, or'simple'
. Default is'html'
.-
numalign
(str
): Alignment of numbers in the table ('right'
,'center'
, or'left'
). Default is'right'
. -
cell_format
(str
): Format of the cell content. The format can take 1 number. Default is'{}'
.
-
top_left_cell_content
(str
): Content of the top left cell which can be used as a label for the table. Default is''
.
Returns:
Name | Type | Description |
---|---|---|
fig |
figure
|
Plotly figure object that can be displayed using |
The plot is based on tabulate.
Source code in exputils/gui/jupyter/tabulate_pairwise.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
|