From b91653555e16192f342016763cb8c764f461dcff Mon Sep 17 00:00:00 2001
From: a-kore <37000693+a-kore@users.noreply.github.com>
Date: Fri, 24 Nov 2023 11:11:54 -0500
Subject: [PATCH] add plots back to quant-analysis section (#512)
* add plots back to quant-analysis section
* add check to see if graphics is not none
---
.../templates/cyclops_generic_template.jinja | 8 ++++
.../kaggle/heart_failure_prediction.ipynb | 48 ++-----------------
2 files changed, 13 insertions(+), 43 deletions(-)
diff --git a/cyclops/report/templates/cyclops_generic_template.jinja b/cyclops/report/templates/cyclops_generic_template.jinja
index 73fe67d46..fa990a7d1 100644
--- a/cyclops/report/templates/cyclops_generic_template.jinja
+++ b/cyclops/report/templates/cyclops_generic_template.jinja
@@ -337,6 +337,14 @@
{{ render_metric_card(metric_card) }}
{% endif %}
{% endfor %}
+ {% if section is hasattr "graphics"%}
+ {% if section.graphics is not none%}
+
+
{{ "Graphics" }}
+ {{ render_if_exist_list(section.graphics) }}
+
+ {% endif %}
+ {% endif %}
{% else %}
{{ render_objects(section) }}
{% endif %}
diff --git a/docs/source/tutorials/kaggle/heart_failure_prediction.ipynb b/docs/source/tutorials/kaggle/heart_failure_prediction.ipynb
index d415fbe56..2722c0ba2 100644
--- a/docs/source/tutorials/kaggle/heart_failure_prediction.ipynb
+++ b/docs/source/tutorials/kaggle/heart_failure_prediction.ipynb
@@ -1232,49 +1232,11 @@
"shutil.copy(f\"{report_path}\", \".\")\n",
"for i in range(4):\n",
" report._model_card.overview = None\n",
- " report._model_card.quantitative_analysis = None\n",
- " results_flat = flatten_results_dict(\n",
- " results=results,\n",
- " remove_metrics=[\"BinaryROCCurve\", \"BinaryPrecisionRecallCurve\"],\n",
- " model_name=model_name,\n",
- " )\n",
- "\n",
- " for name, metric in results_female_flat.items():\n",
- " split, name = name.split(\"/\") # noqa: PLW2901\n",
- " descriptions = {\n",
- " \"BinaryPrecision\": \"The proportion of predicted positive instances that are correctly predicted.\",\n",
- " \"BinaryRecall\": \"The proportion of actual positive instances that are correctly predicted. Also known as recall or true positive rate.\",\n",
- " \"BinaryAccuracy\": \"The proportion of all instances that are correctly predicted.\",\n",
- " \"BinaryAUROC\": \"The area under the receiver operating characteristic curve (AUROC) is a measure of the performance of a binary classification model.\",\n",
- " \"BinaryF1Score\": \"The harmonic mean of precision and recall.\",\n",
- " }\n",
- " report.log_quantitative_analysis(\n",
- " \"performance\",\n",
- " name=name,\n",
- " value=np.clip(metric + np.random.normal(0, 0.1), 0, 1),\n",
- " description=descriptions[name],\n",
- " metric_slice=split,\n",
- " pass_fail_thresholds=0.7,\n",
- " pass_fail_threshold_fns=lambda x, threshold: bool(x >= threshold),\n",
- " )\n",
- "\n",
- " for name, metric in results_flat.items():\n",
- " split, name = name.split(\"/\") # noqa: PLW2901\n",
- " descriptions = {\n",
- " \"BinaryPrecision\": \"The proportion of predicted positive instances that are correctly predicted.\",\n",
- " \"BinaryRecall\": \"The proportion of actual positive instances that are correctly predicted. Also known as recall or true positive rate.\",\n",
- " \"BinaryAccuracy\": \"The proportion of all instances that are correctly predicted.\",\n",
- " \"BinaryAUROC\": \"The area under the receiver operating characteristic curve (AUROC) is a measure of the performance of a binary classification model.\",\n",
- " \"BinaryF1Score\": \"The harmonic mean of precision and recall.\",\n",
- " }\n",
- " report.log_quantitative_analysis(\n",
- " \"performance\",\n",
- " name=name,\n",
- " value=np.clip(metric + np.random.normal(0, 0.1), 0, 1),\n",
- " description=descriptions[name],\n",
- " metric_slice=split,\n",
- " pass_fail_thresholds=0.7,\n",
- " pass_fail_threshold_fns=lambda x, threshold: bool(x >= threshold),\n",
+ " for metric in report._model_card.quantitative_analysis.performance_metrics:\n",
+ " metric.value = np.clip(\n",
+ " metric.value + np.random.normal(0, 0.1),\n",
+ " 0,\n",
+ " 1,\n",
" )\n",
" report_path = report.export(\n",
" output_filename=\"heart_failure_report_periodic.html\",\n",