Cultural Data Analysis

Code-along exercises and interactive tools for the lectures · Tobias Blanke, University of Amsterdam

Open the page for this week's lecture and code along with us. The lecture notebooks open in Colab; each week's workshop has a page with the instructions and a link that opens its notebook. In Colab, always start with File → Save a copy in Drive. The interactive tools are the demonstrations from the slides: try them again at home.

Code along, week by week

Week 0: Python Bootcamp

Getting set up: Colab, Google Drive, the terminal, file paths, and checking an AI agent

Week 1: Python

Code along: three parts, each with exercises in Python Tutor (calculator, variables, types, lists, dictionaries, if … else, loops, functions) and then the matching section of the lecture notebook

Lecture notebook in Colab: the notebook environment, data types, lists and arrays, event-driven and sequential programs (save a copy first)

Computer Programming Spectrum, with the agentic programming overlay

Workshop: Python: the notebook environment, lists and arrays, sequential and event-driven programs, a first real-life dataset

Tools: CPU simulator · Loops in four languages

Week 3: Structured Data and Machine Learning

Code along: machine learning: linear regression, the k-means walkthrough by hand, the teens data

Lecture notebook in Colab: how a machine learns from data, and who decided: a neural network predicts danceability, k-means finds groups among teenagers (save a copy first)

Workshop: data critique and machine learning: the data critique of a donations dataset in groups, then k-means for the US Senate and decision trees for danceability

Tools: Term frequency · How a computer sees an image · Neural network training

Week 4: Cultural Data Forms: Text

Code along: text: bag of words, TF-IDF, list comprehension, 230 years of State of the Union speeches, language models

Lecture notebook in Colab: how a computer reads a text, step by step: tokens, cleaning, counting and tf-idf, named entities, a hate-word dictionary, topic models and word vectors, with State of the Union speeches (save a copy first)

Workshop: text and language models: transformers with Hugging Face, and a group exercise on language models through their APIs (two notebooks to choose from)

Tools: Term frequency · From words to embeddings

Interactive tools

Week 1

CPU simulator

A small von Neumann computer. Step through fetch, decode and execute, and watch a loop run in machine code.

Week 1

Loops in four languages

The same for loop in Assembly, Python, JavaScript and C++, side by side and stepping together: 24 machine instructions against 11 steps.

Weeks 3 and 4

Term frequency

Turn three documents of your own into a bag of words, weight it with TF-IDF, and see which documents come out alike.

Week 3

How a computer sees an image

A photo at 8, 16 or 32 pixels square, as three colour planes of numbers and as one row of features. Upload your own picture too.

Week 3

Neural network training

A network of 12 neurons learns cats from dogs by backpropagation. See which weights change most, and test it on animals it has never seen.

Illustrative data
Week 4

From words to embeddings

Term frequency against real sentence embeddings, and a multimodal space you can train, where words find their nearest pictures.

In every tool: Space step · R reset · P presentation mode · ? all shortcuts.

Elsewhere

A history of AI ethics: the interactive map from the AI ethics lecture, kept in its own repository.