The BMW i3 That Broke `Used-BMW-cars-analytics`
A tidy Colab notebook, one 470-mpg outlier, and the clustering traps that hide in plain sight.
- A single row with engineSize 0.6 and mpg 470.8 can reshape a Euclidean-distance clustering result once the features are standardized.
- The project clusters on price and then describes its clusters by price, which makes the headline 'three market tiers' partly circular.
- The '⚡ BMW i3' cluster the README presents as a market segment is almost certainly one car, not a segment.
- The failure modes here (outliers in distance metrics, target leakage into clustering, documentation drift) ship in production notebooks everywhere.
One Car, Three Broken Assumptions
One row of the CSV does most of the damage. It reads like this:
i3,2016,17100,Automatic,25269,Other,0,470.8,0.6
A 2016 BMW i3, automatic, 25,269 miles, £17,100. Then three values that break the assumptions the rest of the pipeline quietly depends on. The fuel type is Other. The fuel economy is 470.8 miles per gallon. The engine size is 0.6 liters, and per the README, some rows elsewhere in the file sit at 0.0.
Feed those into a StandardScaler and then a Euclidean-distance clustering algorithm, and a single car starts to bend the geometry. The README presents a cluster it labels "⚡ BMW i3" as a market segment. It is almost certainly one car.
Zero engine size values looked like errors at first, but they were valid BMW i3 Electric entries. A small but important reminder to understand your data before touching it.
That instinct is the best moment in the project. The author looked at a column of zeros, decided they were a real category for an electric car rather than a missing-value sentinel, and kept them. It is exactly the kind of domain reasoning a good analyst brings to a messy dataset. It is also the moment the pipeline quietly breaks, because the same row that justifies the zero also carries a 470.8 mpg reading into a distance metric that never saw it coming.
The project is mokhichekhra/Used-BMW-cars-analytics, a single Colab notebook on a public UK used-car dataset. It looks textbook clean. It is wrong in a way a reader can spot in thirty seconds once they know where to look.
A Notebook, Not a Product
The repository is small enough to describe in a breath. One notebook, one CSV, a plain-text feature dictionary, and a README. No directories, no requirements file, no tests, no license, no CI. The language breakdown reports 100 percent Jupyter Notebook, and the course code in the filename, EE56SC, reads like a university module.
- One notebook (roughly 644 KB), the primary analysis.
- One CSV with 10,781 rows before cleaning.
- Nine features: model, year, price, transmission, mileage, fuelType, tax, mpg, engineSize.
- One contributor, with two commits.
A note on evidence before the critique begins. The notebook source available for review was truncated after the Colab upload cell, and the CSV was truncated after roughly a hundred rows. Claims about the modeling pipeline and its metrics below come from the README, not from code that could be fully executed. Where the visible data contradicts the README, that is flagged explicitly. The critique is aimed at the documentation and the design, not at code that could not be run.
The README itself is the most information-dense artifact in the repo, and it has a small tell: its emoji headers and currency symbols are corrupted, rendering as mojibake like ð for 🚗 and £ for £. It is cosmetic, but it signals a copy-paste or export problem, and it fits a larger pattern of documentation that drifted away from the data it describes.
Following the i3 Through the Pipeline
The README describes a recognizable machine learning workflow. Follow the i3 row through it and watch where its values enter the geometry.
- Load: the CSV is uploaded by hand in Colab through
files.upload(), which makes the notebook environment-bound and breaks a clean 'Run all'. - Clean: a null check finds no missing values, and 117 duplicate rows are dropped from 10,781.
- Explore: six plots cover price by model, price against year and mileage, fuel and transmission breakdowns, a correlation heatmap, and engine size against price.
- Encode and scale: categorical features are encoded and numeric features pass through
StandardScaler. This is where the i3's 470.8 mpg becomes a large z-score. - Predict: a regression is fit on
price, and a three-class classifier is fit onprice_category, built withpd.qcut. - Segment: K-Means and Agglomerative Clustering both run at k=3 on the scaled features, and their silhouette scores are compared.
The i3 enters twice: once as a scaled numeric vector, and once as a label the README affixes to a cluster. The first is where it distorts the geometry. The second is where the documentation turns that distortion into a story.
The i3 in Feature Space
After standardization, each feature is rescaled to zero mean and unit variance, and every point's distance is measured in those standardized units. The i3's 470.8 mpg sits far outside the distribution of the rest of the fleet, so its z-score is large. K-Means minimizes Euclidean distance to the nearest centroid, so an extreme point either claims its own centroid or drags one toward it. There is no middle ground where the outlier is absorbed quietly.
The README reports that Agglomerative cluster 2 has an average mpg of 470.8, and labels it "⚡ BMW i3." A cluster mean of exactly 470.8, the single most extreme value in the column, implies that cluster is tiny. Either it holds one listing, or the README is reporting a single row's value as an average, or the number was transcribed by hand from notebook output and lost its context. The repository does not let a reader check which. What can be said plainly is this: a cluster labeled as a market segment, defined by a value that only one type of car in the dataset produces, is almost certainly not a segment. It is the outlier wearing a label.
The Circular Clustering
The i3 is the loudest flaw. The quieter one is structural. The clustering features include price, and the Key Findings then describe the clusters by price tier. A cluster labeled "Premium large-engine" with an average price of £33,275 was partly defined by that price. The notebook found tiers that were, in part, told to it.
This is a form of leakage, and it is common in unsupervised work because nothing throws an error. The model does exactly what it was asked. The story that follows is just less informative than it looks, because the thing the clusters are supposed to explain is already sitting in their inputs.
| What the notebook does | What a cleaner design would do |
|---|---|
| Includes price in the clustering features | Clusters on attributes only: year, mileage, engine, tax, mpg |
| Describes clusters by price tier (Budget, Mid, Premium) | Examines price as an outcome of each cluster |
| Picks K-Means over Agglomerative on a 0.07 silhouette gap | Sweeps k and checks cluster stability before choosing |
| Calls the three clusters 'intuitive market tiers' | Reports silhouette, cluster sizes, and stability as evidence |
The metric choice deserves the same scrutiny. The README reports a K-Means silhouette of 0.3528 against an Agglomerative score of 0.2821, and declares K-Means better. A silhouette near 0.35 is weak-to-moderate structure, and the comparison is two algorithms, one feature set, one value of k. There is no sweep over k, no stability check, and no report of cluster sizes. Calling the result "three intuitive market tiers" is a narrative fit, not a validated finding.
How It Compares
Several adjacent projects do BMW used-car analytics. They differ less in tooling than in what they treat as the point. This project is the only one of the four that treats segmentation as the goal, and the only one whose documentation openly contradicts its own data. Both facts are worth the reader's attention.
| Project | What it does | Deployment | Clustering focus | Data skepticism |
|---|---|---|---|---|
| mokhichekhra/Used-BMW-cars-analytics | EDA, price regression, three-class price classification, K-Means and Agglomerative segmentation | None (Colab notebook) | Central | Moderate; keeps zero-engine rows, but docs drift from data |
| JohnAnih/BMW-used-car-prediction | Price prediction, EDA, model comparison, training pipelines | Dash app | Not a focus | Not emphasized |
| kaiquevalentim/bmw_used_cars_dataset_analisys | Random Forest regressor, interactive dashboard, multi-agent RAG chatbot | Streamlit | Not a focus | Not emphasized |
| Karen2007/BMW-Sales-Analysis | SQL and Python pricing-trend and depreciation analysis | None | Not a focus | High; flags suspicious data and warns against reading it as real market data |
Two caveats. The available research could not confirm that the author's LinkedIn post and this repository describe the same project, and could not verify star counts, which drift and would date any article that leaned on them. The table compares what each repository says it does, not audited code.
What the Project Gets Right
The critique above is real, and so are the strengths. Three stand out, and they are not consolation prizes.
- Quantile binning with
pd.qcutcreates three balanced classes by construction. It sidesteps the class imbalance that fixed price thresholds would produce, at the cost of thresholds that shift when the data does. - Treating
engineSize = 0as a meaningful category rather than a missing-value sentinel is good data reasoning. The execution claim needs checking against the full file, but the instinct is right. - Running K-Means and Agglomerative on the same scaled features and comparing silhouette scores is a reasonable, if minimal, sanity check. Many student projects stop at one algorithm and call it done.
Building an end-to-end ML pipeline from raw data to actionable insights
That framing is the honest one. This is a first-draft coursework project with a clear question, a working workflow, and documentation. What it lacks is the hardening that would make its results trustworthy: validated claims, a reproducible environment, a license, and a clean provenance trail for the data. Those are the next steps, not the verdict.
The Lesson
The i3 is not a bug in this project. It is a mirror. Outliers dominating a distance metric, a target leaking into its own clustering features, documentation drifting away from the data it describes, and a conclusion leaning on a metric that barely supports it: every one of those ships in production notebooks at companies that would never call themselves students.
The fix is not exotic. Scale with an eye on the tails, or log-transform the skewed columns. Cluster on attributes and let price be the outcome, not the input. Report cluster sizes and stability alongside the silhouette. And when a single row carries three values that no other row carries, treat it as the thing to investigate first, not the thing to name a market segment after.





