Exploring Data
Step 1 of the machine learning workflow
Overview
Exploratory data analysis (EDA) is the first step in our machine learning workflow. It involves running general statistical tests to see whether our target variable is worth pursuing, checking for oddities in the data such as missingness, outliers, and correlations, and designing visualizations to help us explore the data further. Together, these steps provide evidence for supporting our research goal, while also offering key insights into how best to work with our data moving forward.
Readings
Before class, read the assigned material and take notes.
Cheat sheets
The following cheatsheets may be helpful for your reference: data storytelling, data visualizations, matplotlib, plotly, seaborn.
Slides
Model workflow
EDA1: Overview of the 5step workflow, learning paradigms, and features types.
Open in new tab
Statistics
EDA2: Descriptive statistics (mean, median, standard deviation), statistical tests and hypothesis testing.
Open in new tab
Visualizations
EDA3: How to tell a story, and creating visualizations with mathplotlib, plotnine, seaborn.
Open in new tab
Homework
This homework goes over looking at summary tables for a dataset, explaining statistical terms to non-tech folks, exploring statistics, and interpretting statistical tests. Click to view pdf.
Lab
In this lab, we will explore how to critique and refine code outputted by a language model, and practice a bit of prompt engineering. We will be using the Titanic dataset to perform exploratory data analysis tasks, including calculating statistical measures, conducting statistical tests, and creating visualizations. Click to view Colab Notebook.
Self-quiz
Use the standards below as a checklist, then try the practice questions to test yourself.
Standards
FLOW
You should be able to:
- Define learning approaches (supervised vs. unsupervised learning) and learning tasks (regression, classification, and clustering).
- Interpret a dataset summary table.
- Describe a model’s goal and explain who might benefit from the model.
- Describe the five steps ML workflow and give a few examples of tasks for each step
EDA-STAT
You should be able to:
- Understand and describe statistical measures, distributions, and tests
- Read and interpret charts, including identifying key features (skew, balance, shape) and chart types (histogram, boxplot, scatterplot)
- Identify different feature types (numeric, discrete, continuous, ordinal, categorical, binary, or none).
- Explain what factors to consider when deciding whether a feature type is appropriate to include in a machine learning model.
Practice questions
Click a question to reveal the answer.
Explain the difference between supervised and unsupervised learning to a friend who has never taken a stats or CS class. Write a 2–3 sentence explanation using non-technical terms (or if you do, explain them). Then, come up with your own real-world analogy to help illustrate the difference.
Supervised learning means we have labels for each of our observations. The model learns general characteristics for each type of label, and then predicts a label for an unseen observation. Unsupervised learning has no labels, so we group observations based on how similar they are.
Analogies may vary.
You are given a histogram of “hours of sleep per night” for 200 college students, and it shows a long tail stretching toward lower values (most students cluster around 7–8 hours, with a few reporting 1–3 hours).
(a) Describe the skew and shape of this distribution.
(b) Would the mean or median better represent the “typical” student in this dataset? Explain why.
(c) What is one other chart type you could use to visualize this same feature, and what additional information might it reveal (e.g., outliers)?
(a) The distribution is left-skewed (mean < median), unimodal (one main peak), and not symmetric
(b) The median would be a better representations since the mean gets pulled in the direction of the tail. This means that it will looks like the average student sleeps less than they actually do. With heavy skews, the median is more robust to outliers/extremes.
(c) A boxplot would be good since it shows the median and IQR (middle 50% range) as well as the mean. This allows us to see general percentage cutoffs (25%, 50%, 75%)