Section 2 · Lesson 2

Explore the data

Find the patterns and quality problems in the listings before you build any model.

You'll learn

Start with questions, not plots

The first two milestones of the project were exploratory data analysis (EDA) and preprocessing. Each EDA question ended in a decision: drop, fix, transform, or keep. The same habit helps you in any project. Before you plot, write down what the answer changes.

The following sections follow the project's findings in that order. Every number comes from the milestone reports and milestone2/ANSWERS.md, except where the text says a course script recomputed it.

Which features carry signal

Milestone 1 ranked features by adjusted mutual information (AMI) on a 30,000-row sample, which measures how much a feature tells you about the tier without assuming a straight-line relationship. zones, max_seats, metro, and access_type ranked highest. The review scores were tightly clustered across tiers, so they help little on their own.

The following figure shows four relationships. Bigger spaces cost more, and so do listings with more facilities. The tier mix also shifts steadily with review_count, and a missing zones value points toward tier 1.

Four panels: mean tier rises with max_seats; facility counts shift right for higher tiers; tier mix by review_count decile; tier mix by missing zones.
Four relationships with the tier, computed by a course script from train.csv. The mean number of facilities rises from 24.5 in tier 1 to 35.4 in tier 4.

Tier 1 makes up 29.7% of the lowest review_count decile and 17.0% of the highest. What does this tell you?

  1. Review count is informative about the tier, even though it's only a weak, monotonic trend.
  2. Review count causes a listing to move to a lower tier.
  3. Review count is useless, because tier 1 is still the smallest share.

The share changes steadily across the deciles, so the feature carries signal. The data can't show causation, and a modest trend can still help a model that combines many features.

Missing values often mean something

About 859,000 cells are missing in the training data. Before you fill any of them, ask why each one is missing. The following figure shows the columns that have gaps.

Horizontal bar chart of missing percentage by column, with borough at 76.7 percent.
Missing values by column (Milestone 2, Figure Q1.1).

The reasons differ by column:

Outliers: real or errors?

review_count has a skew of 5.4 and a maximum of 4,222 against a 99th percentile of 406. operator_portfolio_size has a skew of 16.1 and a maximum of 5,978. By the 1.5 × IQR rule, 10-14% of rows count as outliers in these columns. These listings are real: large operators and popular listings exist. Deleting them would bias the model, so the project transforms them instead (Lesson 3).

A different kind of extreme value is a data error. 62 rows have max_term_days values up to 577 million days, more than 1.5 million years. The 99.9th percentile is exactly 1,125 days, which suggests that 1,125 is the platform's cap and the larger values are placeholders.

Duplicates and redundancy

Facilities

The facilities column is a JSON list of codes such as "FCL-087", with a median of 30 per listing. Both the number of facilities and the specific codes carry signal. Lesson 4 turns them into one binary column per code, which gave the largest gain of any non-target feature.

Charts of facility counts by price tier from Milestone 2.
Facility counts by tier (Milestone 2, Figure Q7.1).

Geography

The coordinates aren't spread evenly across the globe. The 279,746 listings fall into 16 metro areas, and each metro covers a tiny range of latitude and longitude. The average tier differs a lot between metros, from 1.36 in MTR-07 to 3.08 in MTR-11. Within a metro, tiers mix, but some neighborhoods lean one way. A course script generated the following figure.

Left: bar chart of mean tier by metro. Right: scatter of listings inside metro MTR-01 coloured by tier.
Mean tier by metro (left) and the listings of one metro (right).

Filter the listings by metro, tier, and seats

Pick a metro, turn tiers on and off, and raise the minimum seat count. The sample has up to 600 listings per metro. Watch how the tier mix changes in different corners of the metro.

Borough is missing for every listing in 11 of the 16 metros. What is the best way to treat it?

  1. Fill it with the most common borough.
  2. Drop the 77% of rows that lack it.
  3. Give it its own none level, because those metros have no boroughs.

The value is structurally missing, not randomly missing. A separate level keeps the information that the metro has no boroughs, and no rows are lost.