Created
May 30, 2019 08:31
-
-
Save RicherMans/2dbc9ab6f116ea74892fdb8b7e6110ad to your computer and use it in GitHub Desktop.
Plots distribution of scores for AVEC2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
from fire import Fire | |
import plotnine as p | |
def plot(inputfile: str): | |
"""Plots using plotnine Test or dev destirbution of labels | |
:inputfile: str: TODO | |
:returns: TODO | |
""" | |
df = pd.read_csv(inputfile) | |
df['Healthy?'] = df['PHQ8_Binary'].apply(lambda x: "Yes" if x else "No") | |
df['dummy'] = 1 | |
# desc = df['PHQ8_Score'].describe() | |
print(p.ggplot(df, p.aes(x='dummy', y='PHQ8_Score', fill='Healthy?')) | |
+ p.geom_jitter(stat='identity', width=0.2, | |
alpha=0.9, show_legend=False, size=2) | |
+ p.ggtitle('Training data PHQ8 distribution') | |
+ p.labs(x="") | |
+ p.stat_summary(fun_y=np.mean, geom='point', | |
size=4, group='Healthy?', fun_ymin=np.min, fun_ymax=np.max) | |
+ p.coord_flip() | |
# + stat_summary(aes(label='PHQ8_Score'), fun_y=np.mean, geom='text') | |
+ p.stat_summary(fun_data='mean_sdl', | |
fun_args={'mult': 1}, geom='errorbar', size=0.2) | |
+ p.scale_x_continuous(labels=[], breaks=[]) | |
+ p.theme(text=p.element_text(family='Droid Sans Fallback'), | |
figure_size=(10, 4)) | |
) | |
if __name__ == "__main__": | |
Fire(plot) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment