feat(code): Add experimental visualizations for validities

This commit is contained in:
Marty Oehme 2024-02-21 11:28:51 +01:00
parent fe614ab47a
commit c2d20e46ec
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A

View file

@ -160,3 +160,75 @@ sns.pointplot(
x="internal_validity", y="external_validity" 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
)
```