print(np.size(whippet_weight)) print(np.size(terrier_weight)) print(np.size(pitbull_weight)) tstat, pval = f_oneway(whippet_weight, terrier_weight, pitbull_weight) print(pval) v = np.concatenate([whippet_weight, terrier_weight, pitbull_weight]) labels = ['whippet_weight'] * len(whippet_weight) + ['terrier_weight'] * len( terrier_weight) + ['pitbull_weight'] * len(pitbull_weight) tukey_results = pairwise_tukeyhsd(v, labels, 0.05) print(tukey_results) """ We want to see if "poodle"s and "shihtzu"s have significantly different color breakdowns. """ poodle_colors = fetchmaker.get_color("poodle") shihtzu_colors = fetchmaker.get_color("shihtzu") color_table = [[ np.count_nonzero(poodle_colors == "black"), np.count_nonzero(shihtzu_colors == "black") ], [ np.count_nonzero(poodle_colors == "brown"), np.count_nonzero(shihtzu_colors == "brown") ], [ np.count_nonzero(poodle_colors == "gold"), np.count_nonzero(shihtzu_colors == "gold") ], [ np.count_nonzero(poodle_colors == "grey"),
whippet_wg = fm.get_weight("whippet") terrier_wg = fm.get_weight("terrier") pitbull_wg = fm.get_weight("pitbull") pval2 = f_oneway(whippet_wg, terrier_wg, pitbull_wg).pvalue print(pval2) # pval > 0.05 : Not significant weights = np.concatenate([whippet_wg, terrier_wg, pitbull_wg]) labels = ["Whippet"] * len(whippet_wg) + ["Terrier"] * len(terrier_wg) + ["Pitbull"] * len(pitbull_wg) tukey_results = pairwise_tukeyhsd(weights, labels, 0.05) print(tukey_results) # Terrier and Whippet poodle_colors = fm.get_color("poodle") shihtzu_colors = fm.get_color("shihtzu") color_table = [[np.count_nonzero(poodle_colors == "black"),np.count_nonzero(shihtzu_colors == "black")],[np.count_nonzero(poodle_colors == "brown"),np.count_nonzero(shihtzu_colors == "brown")],[np.count_nonzero(poodle_colors == "gold"),np.count_nonzero(shihtzu_colors == "gold")],[np.count_nonzero(poodle_colors == "grey"),np.count_nonzero(shihtzu_colors == "grey")], [np.count_nonzero(poodle_colors == "white"),np.count_nonzero(shihtzu_colors == "white")]] tstats, pvalue, dfr, ef = chi2_contingency(color_table) print(pvalue) # Significant. pvalue < 0.05
if weight_pval < 0.05: print('There is a difference between these breeds!') else: print('There is no difference between these breeds.') from statsmodels.stats.multicomp import pairwise_tukeyhsd weight_pw = np.concatenate( [whippet_avg_weight, terrier_avg_weight, pitbull_avg_weight]) weight_labels = ['whippet'] * len(whippet_avg_weight) + ['terrier'] * len( terrier_avg_weight) + ['pitbull'] * len(pitbull_avg_weight) tukey_results = pairwise_tukeyhsd(weight_pw, weight_labels, 0.05) print(tukey_results) poodle_colors = fetchmaker.get_color('poodle') shihtzu_colors = fetchmaker.get_color('shihtzu') color_table = [[ np.count_nonzero(poodle_colors == 'black'), np.count_nonzero(shihtzu_colors == 'black') ], [ np.count_nonzero(poodle_colors == 'brown'), np.count_nonzero(shihtzu_colors == 'brown') ], [ np.count_nonzero(poodle_colors == 'gold'), np.count_nonzero(shihtzu_colors == 'gold') ], [ np.count_nonzero(poodle_colors == 'grey'),
print pval, num_whippet_rescues, num_whippets from scipy.stats import f_oneway a = fetchmaker.get_weight("whippet") b = fetchmaker.get_weight("terrier") c = fetchmaker.get_weight("pitbull") fstat, pval2 = f_oneway(a, b, c) print pval2 from statsmodels.stats.multicomp import pairwise_tukeyhsd values = np.concatenate([a, b, c]) labels = ['whippet'] * len(a) + ['terrier'] * len(b) + ['pitbull'] * len(c) print pairwise_tukeyhsd(values, labels, .05) poodle_colors = fetchmaker.get_color("poodle") shihtzu_colors = fetchmaker.get_color("shihtzu") from scipy.stats import chi2_contingency color_table = [[ np.count_nonzero(poodle_colors == "black"), np.count_nonzero(shihtzu_colors == "black") ], [ np.count_nonzero(poodle_colors == "brown"), np.count_nonzero(shihtzu_colors == "brown") ], [ np.count_nonzero(poodle_colors == "gold"), np.count_nonzero(shihtzu_colors == "gold")