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
| # 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 |
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
| 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") |
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
| check_normality(test_team) | |
| check_normality(developer_team) | |
| check_variance_homogeneity(test_team, developer_team) |
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
| 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) |
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
| 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) |
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
| 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") |
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
| 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)) |
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
| 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.") |
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
| 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") |
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
| 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") |
NewerOlder