Hypothesis Testing in Python
Hypothesis testing lets you answer questions about your datasets in a statistically rigorous way. Updating ...
Hypothesis testing lets you answer questions about your datasets in a statistically rigorous way. In this course, you'll grow your Python analytical skills as you learn how and when to use common tests like t-tests, proportion tests, and chi-square tests. Working with real-world data, including Stack Overflow user feedback, you'll gain a deep understanding of how these tests work, and the key assumptions that underpin them. You'll also discover how different tests are related using the “there is only one test" framework, before learning how to use non-parametric tests to go beyond the limitations of side-step the requirements of hypothesis tests.
import pandas as pd
import numpy as np
import warnings
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = [8, 6]
pd.set_option('display.expand_frame_repr', False)
warnings.filterwarnings("ignore", category=DeprecationWarning)
warnings.filterwarnings("ignore", category=FutureWarning)
Yum, That Dish Tests Good
How does hypothesis testing work and what problems can it solve? To find out, you’ll walk through the workflow for a one sample proportion test. In doing so, you'll encounter important concepts like z-scores, p-values, and false negative and false positive errors.
To the lab for testing
Uses of A/B testing Calculating the sample mean Calculating a z-score
A tail of two z's
Criminal trials and hypothesis tests Left tail, right tail, two tails Calculating p-values
Statistically significant other
Decisions from p-values Calculating a confidence interval Type I and type II errors
Pass Me ANOVA Glass of Iced t
In this chapter, you’ll learn how to test for differences in means between two groups using t-tests and extend this to more than two groups using ANOVA and pairwise t-tests.
Is this some kind of test statistic?
Hypothesis testing workflow Two sample mean test statistic
Time for t
Why is t needed? The t-distribution From t to p
Pairing is caring
Is pairing needed? Visualizing the difference Using ttest()
P-hacked to pieces
Visualizing many categories ANOVA Pairwise t-tests
Letting the Categoricals Out of the Bag
Now it’s time to test for differences in proportions between two groups using proportion tests. Through hands-on exercises, you’ll extend your proportion tests to more than two groups with chi-square independence tests, and return to the one sample case with chi-square goodness of fit tests.
Difference strokes for proportions, folks
t for proportions? Test for single proportions
A sense of proportion
Test for two proportions proportions_ztest() for two samples
Declaration of independence
The chi-square distribution How many tails for chi-square tests? Chi-square test of independence
Does this dress make my fit look good?
Visualizing goodness of fit Chi-square test of goodness of fit
Time to Define the Relationship
Finally, it’s time to learn about the assumptions made by parametric hypothesis tests, and see how non-parametric tests can be used when those assumptions aren't met.
What do you assume?
Common assumptions of hypothesis tests Testing sample size
Assumptions not met
Which parametric test? Wilcoxon signed-rank test
Look ma! Still no parameters!
Wilcoxon-Mann-Whitney Kruskal-Wallis