|
311 | 311 | "p_values" |
312 | 312 | ] |
313 | 313 | }, |
314 | | - { |
315 | | - "cell_type": "markdown", |
316 | | - "metadata": {}, |
317 | | - "source": [ |
318 | | - "Difference boxplots" |
319 | | - ] |
320 | | - }, |
321 | | - { |
322 | | - "cell_type": "code", |
323 | | - "execution_count": null, |
324 | | - "metadata": {}, |
325 | | - "outputs": [], |
326 | | - "source": [ |
327 | | - "plot_difference_boxplots(results_df)" |
328 | | - ] |
329 | | - }, |
330 | 314 | { |
331 | 315 | "cell_type": "code", |
332 | 316 | "execution_count": null, |
|
368 | 352 | " ax.set_xlabel(\"Age Band\")\n", |
369 | 353 | " ax.set_ylabel(f\"Cohen's kappa score\")\n", |
370 | 354 | " plt.title(f\"Performance by {x}\")\n", |
| 355 | + " \n", |
| 356 | + " handles, _ = ax.get_legend_handles_labels()\n", |
| 357 | + " ax.legend(handles, [\"Baseline\", \"ActiNet\"], title=hue)\n", |
371 | 358 | " plt.show()" |
372 | 359 | ] |
373 | 360 | }, |
|
433 | 420 | " \n", |
434 | 421 | " y_true_bbaa, y_pred_bbaa, y_true_actinet, y_pred_actinet, _ = build_confusion_matrix_data(results_df)\n", |
435 | 422 | " \n", |
436 | | - " plot_confusion_matrix(y_true_bbaa, y_pred_bbaa, 'accelerometer', ax=axs[0], fontsize=fontsize*0.8)\n", |
437 | | - " plot_confusion_matrix(y_true_actinet, y_pred_actinet, 'actinet', ax=axs[1], fontsize=fontsize*0.8)\n", |
| 423 | + " plot_confusion_matrix(y_true_bbaa, y_pred_bbaa, 'Baseline', ax=axs[0], fontsize=fontsize*0.8)\n", |
| 424 | + " plot_confusion_matrix(y_true_actinet, y_pred_actinet, 'ActiNet', ax=axs[1], fontsize=fontsize*0.8)\n", |
438 | 425 | " fig.tight_layout()\n", |
439 | 426 | " plot_and_save_fig(fig, save_path)\n", |
440 | 427 | " \n", |
|
453 | 440 | " subfig.suptitle(f\"{group_by}: {group} (n = {population})\", fontsize=fontsize*0.9)\n", |
454 | 441 | " axs = subfig.subplots(nrows=1, ncols=2, sharey=True)\n", |
455 | 442 | "\n", |
456 | | - " plot_confusion_matrix(y_true_bbaa, y_pred_bbaa, 'accelerometer', ax=axs[0], fontsize=fontsize*0.8)\n", |
457 | | - " plot_confusion_matrix(y_true_actinet, y_pred_actinet, 'actinet', ax=axs[1], fontsize=fontsize*0.8)\n", |
458 | | - " \n", |
| 443 | + " plot_confusion_matrix(y_true_bbaa, y_pred_bbaa, 'Baseline', ax=axs[0], fontsize=fontsize*0.8)\n", |
| 444 | + " plot_confusion_matrix(y_true_actinet, y_pred_actinet, 'ActiNet', ax=axs[1], fontsize=fontsize*0.8)\n", |
| 445 | + "\n", |
459 | 446 | " plot_and_save_fig(fig, save_path)" |
460 | 447 | ] |
461 | 448 | }, |
|
465 | 452 | "metadata": {}, |
466 | 453 | "outputs": [], |
467 | 454 | "source": [ |
468 | | - "generate_confusion_matrices(results_df, save_path=out_dir+\"/plots/conf_full_population.pdf\", fontsize=18)\n", |
469 | | - "generate_confusion_matrices(results_df, group_by=\"Sex\", save_path=out_dir+\"/plots/conf_by_sex.pdf\", fontsize=18)\n", |
470 | | - "generate_confusion_matrices(results_df, group_by=\"Age Band\", save_path=out_dir+\"/plots/conf_by_age.pdf\", fontsize=18)" |
| 455 | + "generate_confusion_matrices(results_df, save_path=out_dir+\"/plots/conf_full_population.png\", fontsize=18)\n", |
| 456 | + "generate_confusion_matrices(results_df, group_by=\"Sex\", save_path=out_dir+\"/plots/conf_by_sex.png\", fontsize=18)\n", |
| 457 | + "generate_confusion_matrices(results_df, group_by=\"Age Band\", save_path=out_dir+\"/plots/conf_by_age.png\", fontsize=18)" |
471 | 458 | ] |
472 | 459 | }, |
473 | 460 | { |
|
483 | 470 | "metadata": {}, |
484 | 471 | "outputs": [], |
485 | 472 | "source": [ |
486 | | - "generate_bland_altman_plots(results_df, save_path=out_dir+\"/plots/ba_full_population.pdf\")\n", |
| 473 | + "generate_bland_altman_plots(results_df, save_path=out_dir+\"/plots/ba_full_population.png\")\n", |
487 | 474 | "generate_bland_altman_plots(results_df[results_df[\"Sex\"]==\"Female\"], subset=\"female\",\n", |
488 | | - " save_path=out_dir+\"/plots/ba_by_sex_female.pdf\")\n", |
| 475 | + " save_path=out_dir+\"/plots/ba_by_sex_female.png\")\n", |
489 | 476 | "generate_bland_altman_plots(results_df[results_df[\"Sex\"]==\"Male\"], subset=\"male\",\n", |
490 | | - " save_path=out_dir+\"/plots/ba_by_sex_male.pdf\")\n", |
491 | | - "generate_bland_altman_plots(results_df, group_by=\"Age Band\", save_path=out_dir+\"/plots/ba_by_age.pdf\")" |
| 477 | + " save_path=out_dir+\"/plots/ba_by_sex_male.png\")\n", |
| 478 | + "generate_bland_altman_plots(results_df, group_by=\"Age Band\", save_path=out_dir+\"/plots/ba_by_age.png\")" |
| 479 | + ] |
| 480 | + }, |
| 481 | + { |
| 482 | + "cell_type": "code", |
| 483 | + "execution_count": null, |
| 484 | + "metadata": {}, |
| 485 | + "outputs": [], |
| 486 | + "source": [ |
| 487 | + "generate_bland_altman_plots(results_df, save_path=out_dir+\"/plots/ba__true_actinet_full_population.png\", compare_to_true='actinet')\n", |
| 488 | + "generate_bland_altman_plots(results_df[results_df[\"Sex\"]==\"Female\"], subset=\"female\",\n", |
| 489 | + " save_path=out_dir+\"/plots/ba__true_actinet_by_sex_female.png\", compare_to_true='actinet')\n", |
| 490 | + "generate_bland_altman_plots(results_df[results_df[\"Sex\"]==\"Male\"], subset=\"male\",\n", |
| 491 | + " save_path=out_dir+\"/plots/ba__true_actinet_by_sex_male.png\", compare_to_true='actinet')\n", |
| 492 | + "generate_bland_altman_plots(results_df, group_by=\"Age Band\", save_path=out_dir+\"/plots/ba__true_actinet_by_age.png\", compare_to_true='actinet')" |
| 493 | + ] |
| 494 | + }, |
| 495 | + { |
| 496 | + "cell_type": "code", |
| 497 | + "execution_count": null, |
| 498 | + "metadata": {}, |
| 499 | + "outputs": [], |
| 500 | + "source": [ |
| 501 | + "generate_bland_altman_plots(results_df, save_path=out_dir+\"/plots/ba_true_bbaa_full_population.png\", compare_to_true='bbaa')\n", |
| 502 | + "generate_bland_altman_plots(results_df[results_df[\"Sex\"]==\"Female\"], subset=\"female\",\n", |
| 503 | + " save_path=out_dir+\"/plots/ba_true_bbaa_by_sex_female.png\", compare_to_true='bbaa')\n", |
| 504 | + "generate_bland_altman_plots(results_df[results_df[\"Sex\"]==\"Male\"], subset=\"male\",\n", |
| 505 | + " save_path=out_dir+\"/plots/ba_true_bbaa_by_sex_male.png\", compare_to_true='bbaa')\n", |
| 506 | + "generate_bland_altman_plots(results_df, group_by=\"Age Band\", save_path=out_dir+\"/plots/ba_true_bbaa_by_age.png\", compare_to_true='bbaa')" |
| 507 | + ] |
| 508 | + }, |
| 509 | + { |
| 510 | + "cell_type": "code", |
| 511 | + "execution_count": null, |
| 512 | + "metadata": {}, |
| 513 | + "outputs": [], |
| 514 | + "source": [ |
| 515 | + "build_mae_table(results_df)" |
| 516 | + ] |
| 517 | + }, |
| 518 | + { |
| 519 | + "cell_type": "code", |
| 520 | + "execution_count": null, |
| 521 | + "metadata": {}, |
| 522 | + "outputs": [], |
| 523 | + "source": [ |
| 524 | + "plot_errors(results_df, save_path = out_dir + \"/plots/errors_full_population.png\")" |
| 525 | + ] |
| 526 | + }, |
| 527 | + { |
| 528 | + "cell_type": "code", |
| 529 | + "execution_count": null, |
| 530 | + "metadata": {}, |
| 531 | + "outputs": [], |
| 532 | + "source": [ |
| 533 | + "plot_errors(results_df, group_by='Age Band', save_path = out_dir + \"/plots/errors_by_age.png\")" |
| 534 | + ] |
| 535 | + }, |
| 536 | + { |
| 537 | + "cell_type": "code", |
| 538 | + "execution_count": null, |
| 539 | + "metadata": {}, |
| 540 | + "outputs": [], |
| 541 | + "source": [ |
| 542 | + "plot_errors(results_df, group_by='Sex', save_path=out_dir + \"/plots/errors_by_sex.png\")" |
492 | 543 | ] |
493 | 544 | } |
494 | 545 | ], |
|
0 commit comments