Skip to content

Instantly share code, notes, and snippets.

View eceisik's full-sized avatar
🌴
On vacation

eceisik

🌴
On vacation
  • Middle East Technical University
View GitHub Profile
# Set formatting and styling options for the confusion matrices
title_size = 16
plt.rcParams.update({'font.size':16})
display_labels = ["Class 1", "Class 2", "Class 3", "Class 4"] # Customize labels of the classes
colorbar = False
cmap = "Blues" # Try "Greens". Change the color of the confusion matrix.
## Please see other alternatives at https://matplotlib.org/stable/tutorials/colors/colormaps.html
values_format = ".3f" # Determine the number of decimal places to be displayed.
# Create subplots for given confusion matrices
@eceisik
eceisik / mannwhitneyu.py
Last active February 22, 2022 08:08
mannwhitneyu
ttest,pvalue = stats.mannwhitneyu(test_team,developer_team, alternative="two-sided")
print("p-value:%.4f" % pvalue)
if pvalue <0.05:
print("Reject null hypothesis")
else:
print("Fail to recejt null hypothesis")
check_normality(test_team)
check_normality(developer_team)
check_variance_homogeneity(test_team, developer_team)
from scipy.stats import chi2
## calculate critical stat
alpha = 0.01
df = (5-1)*(2-1)
critical_stat = chi2.ppf((1-alpha), df)
print("critical stat:%.4f" % critical_stat)
@eceisik
eceisik / chi2_contingency.py
Last active February 18, 2022 18:47
chi2_contingency
from scipy.stats import chi2_contingency
obs =np.array([[53, 23, 30, 36, 88],[71, 48, 51, 57, 203]])
chi2, p, dof, ex = chi2_contingency(obs, correction=False)
print("expected frequencies:\n ", np.round(ex,2))
print("degrees of freedom:", dof)
print("test stat :%.4f" % chi2)
print("p value:%.4f" % p)
@eceisik
eceisik / posthoc_friedman.py
Created February 18, 2022 18:17
posthoc_friedman
data = np.array([method_A, method_B, method_C])
posthoc_df=sp.posthoc_wilcoxon(data, p_adjust="holm")
# posthoc_df = sp.posthoc_nemenyi_friedman(data.T) ## another option for the posthoc test
group_names= ["Method A", "Method B","Method C"]
posthoc_df.columns= group_names
posthoc_df.index= group_names
posthoc_df.style.applymap(lambda x: "background-color:violet" if x<0.05 else "background-color: white")
@eceisik
eceisik / friedman.py
Created February 18, 2022 17:59
friedman
test_stat,p_value = stats.friedmanchisquare(method_A,method_B, method_C)
print("p value:%.4f" % p_value)
if p_value <0.05:
print("Reject null hypothesis")
else:
print("Fail to reject null hypothesis")
print(np.round(np.mean(method_A),2), np.round(np.mean(method_B),2), np.round(np.mean(method_C),2))
@eceisik
eceisik / check_normality_friedman.py
Created February 18, 2022 17:52
check_normality_friedman
check_normality(method_A)
check_normality(method_B)
check_normality(method_C)
print("p value:%.4f" % pvalue_levene)
if pvalue_levene <0.05:
print("Reject null hypothesis >> The variances of the samples are different.")
else:
print("Fail to reject null hypothesis >> The variances of the samples are same.")
@eceisik
eceisik / posthoc_mannwhitney.py
Created February 18, 2022 11:26
posthoc_mannwhitney
posthoc_df = sp.posthoc_mannwhitney([youtube,instagram, facebook], p_adjust = 'bonferroni')
group_names= ["youtube", "instagram","facebook"]
posthoc_df.columns= group_names
posthoc_df.index= group_names
posthoc_df.style.applymap(lambda x: "background-color:violet" if x<0.05 else "background-color: white")
@eceisik
eceisik / kruskal.py
Last active February 18, 2022 11:24
kruskal
F, p_value = stats.kruskal(youtube, instagram, facebook)
print("p value:%.6f" % p_value)
if p_value <0.05:
print("Reject null hypothesis")
else:
print("Fail to reject null hypothesis")