Skip to content

Instantly share code, notes, and snippets.

View trevismd's full-sized avatar

Florian Charlier trevismd

  • Belgium
View GitHub Profile
@trevismd
trevismd / Statannotations-Tutorial-1-23.py
Last active July 21, 2021 15:01
Performing statistical test
with sns.plotting_context('notebook', font_scale = 1.4):
# ... same as before
# Add annotations
annotator.new_plot(ax, pairs=pairs, **plotting_parameters)
annotator.configure(test='Mann-Whitney', verbose=True).apply_and_annotate()
# ... same as before
states_palette = states_palette = sns.color_palette("YlGnBu", n_colors=5)
states_order = ["Successful", "Failed", "Live", "Suspended", "Canceled"]
@trevismd
trevismd / Statannotations-Tutorial-1-22.py
Last active July 7, 2021 20:50
Tweaking text_offset
# Also disabling printed output as it is the same
annotator.configure(text_offset=3, verbose=0)
# Add annotations
annotator.new_plot(ax, **plotting_parameters)
annotator.configure(test_short_name="MWW") # text_format is still simple
annotator.set_pvalues_and_annotate(pvalues)
@trevismd
trevismd / Statannotations-Tutorial-1-20.py
Last active July 21, 2021 15:03
Using simple format
# Add annotations
annotator = Annotator(ax, pairs, **plotting_parameters)
annotator.configure(text_format="simple")
annotator.set_pvalues_and_annotate(pvalues)
@trevismd
trevismd / Statannotations-Tutorial-1-19.py
Last active July 21, 2021 15:01
Annotating with star notation
with sns.plotting_context("notebook", font_scale = 1.4):
# ...Same as previous
# Add annotations
annotator = Annotator(ax, pairs, **plotting_parameters)
annotator.set_pvalues(pvalues)
annotator.annotate()
# ... same as previous
# Putting the parameters in a dictionary avoids code duplication
# since we use the same for `sns.boxplot` and `Annotator` calls
plotting_parameters = {
'data': rfs,
'x': 'Subcategory',
'y': 'Goal',
'palette': subcat_palette[1:]
}
pairs = [('Robots', 'Flight'),
annotator.annotate()
@trevismd
trevismd / Statannotations-Tutorial-1-16.py
Last active July 6, 2021 07:23
Set custom annotations
annotator.set_custom_annotations(formatted_pvalues)
@trevismd
trevismd / Statannotations-Tutorial-1-15.py
Last active July 6, 2021 07:28
Manual tests results
pvalues = [
sci_stats.mannwhitneyu(robots, flight, alternative="two-sided").pvalue,
sci_stats.mannwhitneyu(flight, sound, alternative="two-sided").pvalue,
sci_stats.mannwhitneyu(robots, sound, alternative="two-sided").pvalue
]
# pvalues
# [0.00013485140468088997, 0.2557331102364572, 0.00022985464929005115]
# Transform each p-value to "p=" in scientific notation