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-9.py
Created July 4, 2021 18:40
Extracting arrays to analyse with scipy
robots = rfs.loc[(rfs.Subcategory == "Robots"), "Goal"].values
flight = rfs.loc[(rfs.Subcategory == "Flight"), "Goal"].values
sound = rfs.loc[(rfs.Subcategory == "Sound"), "Goal"].values
log_robots = np.log(robots)
log_flight = np.log(flight)
log_sound = np.log(sound)
print("Robots: ", normaltest(robots).pvalue)
print("Flight: ", normaltest(flight).pvalue)
print("Sound: ", normaltest(sound).pvalue)
print()
print("Log(robots): ", normaltest(log_robots).pvalue)
print("Log(Flight): ", normaltest(log_flight).pvalue)
print("Log(Sound): ", normaltest(log_sound).pvalue)
# pvalues with scipy:
stat_results = [
mannwhitneyu(robots, flight, alternative="two-sided"),
mannwhitneyu(flight, sound, alternative="two-sided"),
mannwhitneyu(robots, sound, alternative="two-sided")
]
pvalues = [result.pvalue for result in stat_results]
print("Robots vs Flight: \n", stat_results[0], "\n")
@trevismd
trevismd / Statannotations-Tutorial-1-13.py
Last active July 9, 2021 07:01
Box pairs for plot 1
pairs = [('Robots', 'Flight'), # 'Robots' vs 'Flight'
('Flight', 'Sound'), # 'Flight' vs 'Sound'
('Robots', 'Sound')] # 'Robots' vs 'Sound'
from statannotations.Annotator import Annotator
@trevismd
trevismd / Statannotations-Tutorial-1-14.py
Last active July 5, 2021 08:11
Instantiate Annotator
# With ... = all parameters passed to seaborn's plotter
annotator = Annotator(ax, box_pairs, ...)
@trevismd
trevismd / Statannotations-Tutorial-1-14.py
Last active July 9, 2021 07:01
Instantiate Annotator
# With ... = all parameters passed to seaborn's plotter
annotator = Annotator(ax, pairs, ...)
@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
@trevismd
trevismd / Statannotations-Tutorial-1-16.py
Last active July 6, 2021 07:23
Set custom annotations
annotator.set_custom_annotations(formatted_pvalues)
annotator.annotate()