← All weeks and tools

Workshop: data critique and machine learning

Cultural Data Analysis · Week 3: Structured Data and Machine Learning

This week's workshop has two parts: a 30-minute data critique in groups, and the machine learning workshop with clustering and decision trees.

First: save your own copy. Unless the notebook is already in your own Google Drive, Colab does not keep your changes. Go to File → Save a copy in Drive and work in the copy that opens in a new tab. You find it later in Google Drive, in Colab Notebooks.

  1. Data critique: ten questions for structured data (30 min, in groups)
  2. The practice case: Global Aid Alliance
  3. Machine learning workshop
  4. The full audit checklist for your group project

1. Data critique: ten questions for structured data

Every dataset was made by someone, for some purpose, about some people. This week is about structured data: tables of rows and columns, as in a spreadsheet or a database. Before we analyse such a table, and before a machine learns from it, we ask what it is, who made it, who is in it and who is left out, and what happens when its columns become a label (what a model predicts) and features (what it predicts from).

Use the ten questions below on every table of data you work with: the Senate votes and Spotify songs in the next hour, and the tables in your group project. Today we practise them on one case, the donation records of a (fictional) NGO. The questions also help with text corpora, though some will need adapting.

Mostly thinking, not coding. Most questions are answered by reading the data sheet, looking at the rows and discussing. For each answer, say what it rests on: the data sheet says …, we saw in the data …, or we assume …. Code is there if you want to check a suspicion.

The 30 minutes

MinutesWhat
0–5Read the case and the data sheet below; look at the first rows of the data
5–20In your group, work through the ten questions. Write a sentence or two per question in the data critique template (below)
20–30All together: each group brings its strongest point, then question 10: can this data answer the NGO's question?

The ten questions

Write your answers in the data critique template, a Markdown file with the ten questions, room for your answers, and after each answer what it rests on. It is a short version of Datasheets for Datasets (Gebru et al.). Download it, fill it in for today's case, and use a copy for every table in your group project.

The data critique templatedata_critique_template.md · use the download button on that page

The right-hand column says where to look in today's case.

#Question (for any table of data)In the donor case, look at …
The data: where it comes from
1Who made this data, for what purpose, and with what system or process? Whose question was it made to answer?Who wrote the data sheet, and what do they want from the data?
2What does one row stand for, and what is outside the data: which people, periods or cases, and why?The export filter, and the three ways gifts come in.
3Which categories did someone design (gender, region, age bands …)? What can't be said in them?The columns gender, age_range, region and campaign.
4What looks missing, wrong or inconsistent? Is it a mistake, or a trace of how the data was made?The dates and campaigns, the age and gender of cheque donors, and what a donor ID really identifies.
The label: what a model would predict
5What would the label be for the question being asked? Who defines it, and is it a proxy for what we actually care about?There is no "retention" column. How would you make one, and what would it count as a loyal donor?
6Where do the features come from: measured, chosen by the people themselves, typed in by someone else, or computed by another system?Who filled in each column, and on which channel?
The people: who is in it and who is affected
7Who are the people in the data? Did they know, did they agree, and did they agree to this use?The last line of the data sheet, and what "donor retention" means for the donors.
8Which attributes are personal or sensitive, or could reveal something sensitive in combination? Could someone be identified?Names, and what name, region, age band and a gift to a particular appeal say together.
9Who could benefit, and who could be harmed or left out, if the analysis is used?Donors who give little, or by cheque; and the people the NGO is supposed to help.
Together
10Can this data answer the question at all? What would you need to know, or whom would you need to ask, before trusting it?The NGO's question: understand donation patterns, improve fundraising, keep donors.

2. The practice case: Global Aid Alliance

A disaster relief NGO, Global Aid Alliance, has exported five years of donation records. It wants to understand donation patterns, improve fundraising efficiency and increase donor retention: keeping donors giving. Can the data do this, and should it be used this way?

Global Aid Alliance is a fictional organisation; the data are made up for teaching. Read the data sheet as if it were real: it is the organisation's own account of its data, and like any such account it may be incomplete or wrong.

Look at the data in ColabWeek3_Data_Critique.ipynb

The notebook loads donor_records_export.csv and helps you test what you write about the label and the features: it makes a label in three ways, shows whom each favours, where the features come from, and whether a column gives away a sensitive one. It works on any table: use it again for the data of your group project.

Data sheet for donor_records_export.csv

From: Fundraising & Development, Global Aid Alliance
Purpose of the export: to understand donation patterns, improve fundraising efficiency and increase donor retention.

What the file contains

How the data are collected

Columns

ColumnMeaning
donation_idUnique ID of the donation
donor_idUnique ID of the donor
donor_nameName as given by the donor
donation_dateDate the gift was received
donation_amountAmount of the gift
currencyCurrency of the gift; all gifts are converted to USD
channelHow the gift was made: Online, Mail or Event
campaignThe appeal the gift responded to, or General Fund if the donor did not choose one
regionRegion (continent) of the donor's address
age_rangeAge band of the donor
genderGender of the donor: Female, Male, Non-binary, Prefer not to say
recurring_giftYes if the gift is part of a monthly direct debit

Privacy: donors agree to our privacy notice when they give. Analysis for fundraising purposes is covered by it.

3. Machine learning workshop

Clustering and classification with scikit-learn: k-means finds voting blocs among US senators, and decision trees and a random forest predict whether a song is danceable. Take the ten questions with you: who made the Senate and Spotify data, what are the label and the features, who decided the categories, and who is in the data?

Open in ColabWeek3_Workshop.ipynb

To submit: run the whole notebook and complete every cell marked #Complete cell. Sections and cells marked optional you can skip.

Run the first code cell to set up the checks. Below an exercise, q1.check() checks your answer, q1.hint() gives a hint and q1.solution() the solution: try first.

Hand it in

The last cell of the notebook makes an HTML file of your notebook and downloads it. Save the notebook first, run the cell, check the HTML file, and upload it to Canvas.

The code-along for this week's lecture: machine learning.

4. The full audit checklist for your group project

The ten questions are the core. This is the full Structured Data Audit Checklist from the lecture: use it for the data your group collects, before any analysis or modelling.

Context & provenance

Structure & schema

Data quality & integrity

Statistical & distributional checks

Ethical & interpretive considerations

Readiness for analysis / modelling