Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small fix to notebooks #514

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 5 additions & 43 deletions docs/source/tutorials/mimiciv/mortality_prediction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1228,49 +1228,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_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=\"mortality_report_periodic.html\",\n",
Expand Down
32 changes: 6 additions & 26 deletions docs/source/tutorials/synthea/los_prediction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@
"report.log_plotly_figure(\n",
" fig=conf_plot,\n",
" caption=\"Confusion Matrix\",\n",
" section_name=\"fairness analysis\",\n",
" section_name=\"quantitative analysis\",\n",
")\n",
"conf_plot.show()"
]
Expand Down Expand Up @@ -1460,31 +1460,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",
" for name, metric in results_flat.items():\n",
" split, name = name.split(\"/\") # noqa: PLW2901\n",
" if name == \"BinaryStatScores\":\n",
" continue\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=\"length_of_stay_report_periodic.html\",\n",
Expand Down
Loading