Statistical modeling with Python
Hypothesis tests, linear regression, GLMs such as logistic and Poisson regression, model checks and prediction with statsmodels, SciPy and scikit-learn.
Learn the statistical models analysts use every day and run each one in your browser: t-tests and chi-square tests, linear regression, logistic regression as a GLM, odds ratios, Poisson regression for counts, comparing models with AIC and likelihood-ratio tests, and predicting on new data. Every lesson explains how to read the numbers, not just how to get them. statsmodels, SciPy and scikit-learn load in your browser the first time you run code, so there is nothing to install.
- 1Statistical modeling in Python: the toolboxMeet statsmodels, SciPy and scikit-learn, fit your first regression in five lines, and learn when to use formulas and when arrays.14 min
- 2Describing data: mean, median and spreadSummarise a column before you model it: mean and median, standard deviation, quantiles and IQR, group summaries and a box plot.13 min
- 3Probability distributions with scipy.statsUse the normal, binomial and Poisson distributions in scipy.stats: pdf and pmf, cdf for 'at most', sf for 'more than', and ppf for cut-offs.15 min
- 4Confidence intervals in PythonCompute a 95% confidence interval for a mean with scipy.stats.t and for a proportion with statsmodels, and learn what the interval really says.13 min
- 5Hypothesis tests in Python: t-testsRun one-sample, two-sample (Welch) and paired t-tests with scipy.stats, and read p-values honestly: what they say and what they do not.17 min
- 6Chi-square test and tests for proportionsTest whether two categories are linked with chi2_contingency, compare two conversion rates with a z-test, and test one share with binomtest.15 min
- 7Correlation in Python: Pearson and SpearmanMeasure how two columns move together with Pearson and Spearman correlation, test it with SciPy, and avoid the classic traps.14 min
- 8Linear regression in Python with statsmodelsFit a simple linear regression with statsmodels' formula API and read every number: slope, R-squared, p-values, confidence intervals, predictions.18 min
- 9Multiple regression and categorical variablesAdd several predictors to a regression, read each coefficient 'holding the others fixed', use text columns with C(), reference levels and interactions.18 min
- 10Checking a regression: residuals and VIFCheck a linear regression before you trust it: residuals and the residual plot, influential points with Cook's distance, and multicollinearity with VIF.17 min
- 11GLMs explained: family and link functionWhat a generalized linear model is: a family for the outcome plus a link function. See that linear regression is a Gaussian GLM, and when to use each family.15 min
- 12Logistic regression in Python (GLM)Run a logistic regression as a GLM with statsmodels, turn coefficients into odds ratios, read them in plain words and predict probabilities.20 min
- 13Evaluating logistic regression: ROC and AUCHow good is a logistic model? Confusion matrix, accuracy, precision and recall, ROC curve and AUC with sklearn.metrics, and how to choose a threshold.17 min
- 14Poisson regression for count data in PythonModel counts with a Poisson GLM in statsmodels: rate ratios, exposure and offsets for different time periods, predictions and the overdispersion check.17 min
- 15Comparing models: AIC and cross-validationChoose between models with AIC and BIC, test nested models with a likelihood-ratio test, and score predictions on unseen data with cross-validation.18 min
- 16Project: predict which customers buyAn end-to-end logistic regression: explore 120 shoppers, fit a GLM, drop a weak predictor, read odds ratios, check AUC and chart the probability.22 min