From c2d20e46ec477661cc61294215af08dd1a72816a Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 21 Feb 2024 11:28:51 +0100 Subject: [PATCH] feat(code): Add experimental visualizations for validities --- 00-notebooks/rank_validities.qmd | 72 ++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/00-notebooks/rank_validities.qmd b/00-notebooks/rank_validities.qmd index e6a5c80..2544a94 100644 --- a/00-notebooks/rank_validities.qmd +++ b/00-notebooks/rank_validities.qmd @@ -160,3 +160,75 @@ sns.pointplot( x="internal_validity", y="external_validity" ) ``` + +As a relation-chart which shows the internal-external relation and the deviation from individual points. + +```{python} +#| label: fig-validity-relation +#| fig-cap: "Relation between internal and external validity" +#| fig-height: 5 +#| code-fold: true + +from src.model import validity + +validities = validity.calculate(by_intervention) +validities["identifier"] = validities["author"].str.replace(r',.*$', '', regex=True) + " (" + validities["year"].astype(str) + ")" +validities = validities.loc[(validities["design"] == "quasi-experimental") | (validities["design"] == "experimental")] +#validities["external_validity"] = validities["external_validity"].astype('category') +validities["internal_validity"] = validities["internal_validity"].astype('category') + +sns.pointplot( + data=validities, + x="internal_validity", y="external_validity", +) +``` + +```{python} +#| label: fig-validity-distribution +#| fig-cap: "Distribution of internal validities" +#| fig-height: 5 +#| code-fold: true + +fig, ax = plt.subplots() + +#sns.displot( +# data=validities, +# x="external_validity", hue="internal_validity", +# kind="kde", +# multiple="fill", clip=(0, None), +# palette="ch:rot=-0.5,hue=1.5,light=0.9", +# bw_adjust=.65, cut=0, +# warn_singular = False +#) +``` +Following plots need at least one axis, preferably external to be set to categorical. + +As a heatmap plot for categorical data between x-y: + +```{python} +#| label: fig-validity-distribution +sns.displot( + data=validities, + x="internal_validity", y="external_validity", hue="design", + palette="ch:rot=-0.75,hue=1.5,light=0.9", +) +``` + +As a violin plot showing distribution of external along internal category: + +```{python} +sns.violinplot( + data=validities, + x="internal_validity", y="external_validity", hue="design", + cut=0, bw_method="scott", + orient="x" +) +# optional swarmplot showing the actual amount of data points for each rank +sns.swarmplot( + data=validities, + x="internal_validity", y="external_validity", + color="red", + s=6 +) +``` +