Find a course

Module 1: Creative Development and DataLesson 3 of 1112 min

Compression, Metadata and Data Analysis

Compare lossless and lossy compression, use metadata, and learn how cleaning, filtering and visualizing data reveal patterns while watching for bias.

Step 1 of 10Learn

Making files smaller

A one-hour video in raw form would take hundreds of gigabytes. Streaming services send it in a tiny fraction of that size thanks to compression: storing the same information, or almost the same, in fewer bits.

Lossless compression shrinks data in a way that can be reversed exactly. A simple example is run-length encoding: instead of storing AAAAAABBBCC, store 6A3B2C. Nothing is lost; you can rebuild the original perfectly. ZIP files and PNG images use lossless methods. They're essential when every bit matters: documents, program files, medical scans, spreadsheets.

Lossy compression throws away details people are unlikely to notice, such as subtle color shifts in a photo or very high sound frequencies. The original can never be fully restored, but the file can become much smaller. JPEG photos, MP3 and most streaming audio, and most video formats are lossy.

The trade-off is simple to state: lossless guarantees perfect reconstruction; lossy gives a greater size reduction. Which one to use depends on whether exactness matters more than size. A photographer sending images to be printed might choose lossless; a social app showing thousands of thumbnails chooses lossy to save bandwidth and loading time.

Lossless vs. lossy compressionLosslessRebuilds the original exactlySmaller savingsZIP, PNG, run-length encodingDocuments, code, medical scansLossyThrows away details you may not noticeMuch smaller filesJPEG, MP3, most videoPhotos online, streaming

Step 2 of 10Practice · Sort into groups

Would lossless or lossy compression be the better choice?

Tap an item, then tap its group (or drag it there).

Step 3 of 10Practice · Work it out

Using run-length encoding that writes each run as a count followed by the character, how many characters long is the encoded version of WWWWWWWWBBBWWWW?

Step 4 of 10Learn

Data about data

Metadata is data that describes other data. A photo's pixels are the data; its metadata includes the date and time it was taken, the camera model, the image size and often the GPS location. A song file's metadata includes the title, artist and album.

Metadata is incredibly useful. It lets you search photos by date, sort music by artist and organize files without opening them. Changing or deleting metadata doesn't change the main data itself: renaming a song's album tag leaves the music untouched.

But metadata can reveal more than people expect. Researchers have shown that phone metadata alone, meaning who called whom, when and from where, without any content of the calls, can reveal where someone lives, works and spends their time. Posting a photo with location metadata can reveal your home address.

Using data to learn things. Large data sets let people find patterns that no one could see by hand: which bus routes are overcrowded, which songs trend in which cities, how a disease spreads. Data scientists usually follow a sequence: collect the data, clean it (fix inconsistent entries, remove duplicates and invalid values), filter and transform it to focus on the question, then visualize it with charts and tables to spot trends.

Step 5 of 10Flashcards

Data or metadata?

Tap a card to flip it.

Step 6 of 10Practice · Put in order

Put these steps of a data analysis project in a sensible order.

Drag the items, or use the arrow buttons, to put them in order.

  1. Filter the data to only the grades you're studying
  2. Collect survey responses from students
  3. Draw a conclusion and note its limits
  4. Clean the data by removing duplicates and fixing inconsistent spellings
  5. Create a chart to look for patterns

Step 7 of 10Learn

Correlation, bias and limits

Data can mislead as easily as it informs. Three cautions appear again and again in computer science.

Correlation is not causation. Ice cream sales and swimming pool accidents both rise in summer. They're correlated, but ice cream doesn't cause accidents; hot weather drives both. Finding that two things change together is a starting point for investigation, never proof that one causes the other.

Bias in data. If a data set doesn't represent the whole population, conclusions will be skewed. An online survey about internet access will undercount people without internet. A face recognition system trained mostly on photos of one group may work poorly for others. Collecting more data of the same kind doesn't fix bias; collecting more representative data does.

Scale and processing. Some data sets are so large that a single computer can't handle them in reasonable time, which leads to techniques like parallel and distributed computing that you'll meet later. Even then, the quality of a conclusion depends on the quality of the data. Programmers sum this up with an old phrase: garbage in, garbage out.

When you read a claim based on data, ask: who was measured, how, and what else could explain the pattern?

Step 8 of 10Tap to reveal

Three ways data misleads

  1. Correlation, not causation

    Ice cream sales and pool accidents rise together because hot weather drives both. A pattern alone does not prove one causes the other.

  2. Biased samples

    Data collected only from some people (an app only smartphone owners use, a survey only in the library) can paint the wrong picture of everyone.

  3. Missing or messy data

    Duplicates, typos and blanks can change results. That is why cleaning comes before analysis.

Step 9 of 10Note

Step 10 of 10Practice · What would you do?

What would you do?

A city collects complaints about potholes through a smartphone app, then sends repair crews to the neighborhoods with the most reports. A council member worries the data is biased. Which concern is most valid?