HTML Firebase Python PCA

Geography-Quiz

A web geography quiz and its Python analysis pipeline, built to gather and analyze data for a statistics class · testing whether Americans and Europeans know each other’s geography equally well.

Overview

For the MS1 “Survey in Action” assignment in my Math and Statistics course, my partner Ella and I designed a survey that would answer a fun but testable question: do Americans or Europeans know each other’s geography better? The project is two linked repos: Geography-Quiz builds the survey instrument, and Geography-Quiz-Analysis pulls, cleans, and analyzes the responses.

The result is a complete data-collection-to-analysis workflow: a live web quiz on Firebase, participant data in a Firebase Realtime Database, and a Python pipeline that maps the results. PCA and k-means clustering then show who knows whose geography.

The survey (Geography-Quiz)

Each participant answers 40 randomly selected questions · 20 U.S. states and 20 European countries. They click answers on SVG maps with immediate right/wrong feedback. Participants can optionally provide a name and country of origin (recommended, since it drives the study’s grouping). Responses go to a Firebase Realtime Database for later analysis.

  • Vanilla HTML + CSS + JS with embedded SVG maps of the U.S. and Europe.
  • Randomized 40-question session with instant right/wrong feedback and a final score.
  • Country-of-origin field captured per participant to compare Americans, Europeans, and everyone else.
  • Deployed on Firebase Hosting with a Realtime Database backend.
  • Self-selected participation · a convenience sample, which the assignment asks us to reflect on as a bias.

The analysis (Geography-Quiz-Analysis)

The analysis repo pulls the collected responses, cleans them, and produces choropleth-style map outputs along with PCA and k-means clustering of the response data.

  • firebase_Obj.py · a GeoPull class that authenticates to Firebase Firestore, downloads responses, normalizes fields, and drives every output.
  • geoPull_Script.py / main.py · data pulls on 24-4-25 and 5-5-25, with per-country (e.g. Austria), per-correctness, and combined map and PCA exports.
  • Choropleth maps of response data across U.S. states and European countries.
  • PCA + k-means (sklearn) on standardized correctness/response matrices to reveal clusters of similar answering behaviour · e.g. which countries group together.
  • Tracked data pulls as dated folders with both raw and cleaned CSVs.
PCA output across European countries from the Geography-Quiz analysis
PCA + k-means output across European countries (combined data pull, 5-5-25).
PCA output across U.S. states from the Geography-Quiz analysis
PCA + k-means output across U.S. states (combined data pull, 5-5-25).

Tech & Approach

Survey side: hand-written HTML/CSS/JS with embedded SVG maps and Firebase Hosting + Realtime Database for collection. Analysis side: Python 3 with firebase_admin (Firestore), pandas / numpy for data handling, matplotlib for the map visualizations, and sklearn (PCA, KMeans, StandardScaler) for the clustering analysis. Country-of-origin fields allow grouping into U.S., Europe, and combined sets.

Outcome

The pipeline went from a live quiz to cleaned, clustered results: multiple dated data pulls (4-4, 11-4, 24-4, 5-5), choropleth maps of correctness by region, and PCA/k-means outputs for Europe, the U.S., Austria-only, and combined groups. It delivered the full “survey in action” workflow · design, collect, clean, analyze, and present · and produced the visual evidence used in the class presentation.