-
Notifications
You must be signed in to change notification settings - Fork 0
/
Match_Maker Tech Startup.py
104 lines (56 loc) · 2.92 KB
/
Match_Maker Tech Startup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import numpy as np
import fetchmaker
from scipy.stats import binom_test
from scipy.stats import f_oneway
from statsmodels.stats.multicomp import pairwise_tukeyhsd
from scipy.stats import chi2_contingency
print(np.mean(fetchmaker.get_tail_length('rottweiler')))
print(np.std(fetchmaker.get_tail_length('rottweiler')))
# Binomial Test
whippet_rescue = fetchmaker.get_is_rescue('whippet')
num_whippet_rescues = np.count_nonzero(whippet_rescue)
num_whippets = np.size(whippet_rescue)
pval_binom = binom_test( num_whippet_rescues, num_whippets, 0.08)
if pval_binom < 0.05:
print('\nWhippets are significantly more likely to be rescue.')
elif pval_binom > 0.05:
print('\nWhippets are significantly less likely to be rescue. Null hypothesis is True')
#### Whippets are significantly less likely to be rescue. Null hypothesis is True
# ANOVA Test
fstat, pval_anova = f_oneway((fetchmaker.get_weight("whippet")), (fetchmaker.get_weight("pitbull")), (fetchmaker.get_weight("terrier")))
if pval_anova < 0.05:
print('\nThere is a significant difference in weights among these 3 Dogs. Lets proceed to Tukey\'s HSD')
elif pval_anova > 0.05:
print('\nThese Dogs has no difference in weights. Just a random error.\n')
#### There is a significant difference in weights among these 3 Dogs. Lets proceed to Tukey's HSD
## Tukey's HSD
dogs = np.concatenate([(fetchmaker.get_weight("whippet")), (fetchmaker.get_weight("terrier")), (fetchmaker.get_weight("pitbull"))])
labels = ['whippet'] * len((fetchmaker.get_weight("whippet"))) + ['terrier'] * len((fetchmaker.get_weight("terrier"))) + ['pitbull'] * len((fetchmaker.get_weight("pitbull")))
sig_result = pairwise_tukeyhsd(dogs, labels, 0.05)
print(sig_result)
#### Pitbull, terrier Differ from each other
#### Pitbull, Whippet don't Differ from each other
#### Terrier, Whippet Differ from each other
# Chi2- Test
poodle_colors = fetchmaker.get_color("poodle")
shihtzu_colors = fetchmaker.get_color("shihtzu")
shitzu_brown = np.count_nonzero(shihtzu_colors == "brown" )
shitzu_black =np.count_nonzero(shihtzu_colors == "black" )
shitzu_gold =np.count_nonzero(shihtzu_colors == "gold" )
shitzu_grey =np.count_nonzero(shihtzu_colors == "grey" )
shitzu_white =np.count_nonzero(shihtzu_colors == "white" )
poodle_brown =np.count_nonzero(poodle_colors == "brown" )
poodle_black =np.count_nonzero(poodle_colors == "black" )
poodle_gold =np.count_nonzero(poodle_colors == "gold" )
poodle_grey =np.count_nonzero(poodle_colors == "grey" )
poodle_white =np.count_nonzero(poodle_colors == "white" )
color_table = [[poodle_black, shitzu_black],
[poodle_brown, shitzu_brown],
[poodle_gold, shitzu_gold],
[poodle_grey, shitzu_grey],
[poodle_white, shitzu_white]
]
chi2, pval_chi2, dof, expected = chi2_contingency(color_table)
print(pval_chi2)
#### 0.00530240829324
#### poodle"s and "shihtzu"s have significantly different color breakdowns.