Case Study 01

Car Price Prediction from Jiji Listings (Ghana)

This case study builds a linear regression workflow that predicts vehicle listing price from structured attributes scraped from Jiji car listings in Ghana.

1) Data pipeline

Two scripts power this pipeline:

  • scripts/scrape-jiji-cars.mjs: Scrapes listing features + listing date + price.
  • scripts/export-jiji-cars-to-bq.mjs: Loads cleaned NDJSON into BigQuery.

2) BigQuery target table

Destination table: binabyte.price_predictor.cars

Key model fields include: price (target), make, model, year, condition, transmission, fuel_type, body_type, mileage_km, location_region, location_city, seller_badge, listing_date.

3) Linear regression in BigQuery ML

Train a baseline model directly in BigQuery using one-hot encoding via TRANSFORM:

CREATE OR REPLACE MODEL `binabyte.price_predictor.car_price_lr`
OPTIONS (
  model_type = 'LINEAR_REG',
  input_label_cols = ['price'],
  data_split_method = 'AUTO_SPLIT'
) AS
SELECT
  price,
  year,
  mileage_km,
  IFNULL(make, 'UNKNOWN') AS make,
  IFNULL(model, 'UNKNOWN') AS model,
  IFNULL(condition, 'UNKNOWN') AS condition,
  IFNULL(transmission, 'UNKNOWN') AS transmission,
  IFNULL(fuel_type, 'UNKNOWN') AS fuel_type,
  IFNULL(body_type, 'UNKNOWN') AS body_type,
  IFNULL(location_region, 'UNKNOWN') AS location_region,
  IFNULL(location_city, 'UNKNOWN') AS location_city,
  IFNULL(seller_badge, 'UNKNOWN') AS seller_badge,
  EXTRACT(YEAR FROM listing_date) AS listing_year,
  EXTRACT(MONTH FROM listing_date) AS listing_month
FROM `binabyte.price_predictor.cars`
WHERE price IS NOT NULL;