Experimenteel ontwerpen in Python
James Chapman
Curriculum Manager, DataCamp

X had waarschijnlijk effect op Y. Er is waarschijnlijk een klein risico op fout
P-waardeanalyse geeft aan dat X effect had op Y met 10% risico op Type I-fout
Nuttig in veel domeinen:





heights id height
0 0 177.98
1 1 174.17
2 2 178.89
Toewijzing door de DataFrame te slicen
group1_nonrandom = heights.iloc[0:100,:] group2_nonrandom = heights.iloc[100:,:]compare_df = pd.concat( [group1_nonrandom['height'].describe(), group2_nonrandom['height'].describe()], axis=1) compare_df.columns = ['group1', 'group2'] print(compare_df)
group1 group2
count 100.00 100.00
mean 170.32 179.19 <--
std 3.28 3.50
min 159.28 175.03
25% 168.06 176.57
50% 170.75 178.03
75% 173.09 180.79
max 174.92 191.32
.sample()n of frac (fractie 0-1)group1 = heights.sample(frac=0.5, replace=False, random_state=42)group2 = heights.drop(group1.index)
print(compare_df)
group1 group2
count 100.00 100.00
mean 175.10 174.41 <--
std 5.39 5.78
min 163.07 159.28
25% 171.32 170.17
50% 175.22 174.86
75% 178.32 177.85
max 189.78 191.32
.sample().describe()
Experimenteel ontwerpen in Python