Preview of the House price prediction project
Data / AICompleted

House price prediction

A complete ML pipeline on the Ames Housing dataset, comparing 5 models with SHAP analysis.

Status

Completed

Period

August 2026

Context

Personal

Field

Data / AI

Technologies

PythonpandasNumPyscikit-learnXGBoostSHAPSupervised learning

01The project

This is my second personal AI project, carried out right after my image classification. Like the first one, its main goal was to improve my skills. This time, I wanted to discover "classic" Machine Learning, which works on tables of data rather than on images.

The goal was to predict the sale price of a house from its features (area, neighborhood, build quality, garage...). I used the Ames Housing dataset, which describes about 1,500 houses sold in the United States, with nearly 80 pieces of information each.

02Step 1, preparing the data

A model only learns well if the data is clean. This is the step that took me the most time, and the one that mattered the most.

Empty cells

Some information was missing, but not always for the same reason. Sometimes, an empty cell simply meant "absent" (no pool, no garage...), and I replaced it with "None". Other times, the value necessarily existed but hadn't been filled in, like the width of the lot. I then replaced it with the most common value.

The price distribution

Most houses have an average price, and a few are very expensive. These extreme prices disrupted the learning. I therefore applied a logarithmic transformation, which narrows large gaps and makes the price distribution more balanced.

On the left, prices pile up on one side with a long tail of expensive houses. On the right, after transformation, they form a much more regular bell curve, easier for a model to learn.

Outliers

A few huge houses had been sold at an abnormally low price, probably special sales. Since they could distort the model, I removed them.

From text to numbers

A model only understands numbers, so the information written as text had to be converted. When a piece of information followed a logical order, like a quality ranging from "Poor" to "Excellent", I turned it into a score from 0 to 5 to keep that order. When it didn't, like the neighborhood name, I created a "yes / no" column for each possibility.

The houses set aside

I set aside 20% of the houses, which the model never sees during training. They are used at the end to check whether it can really predict the price of houses it doesn't know.

03Step 2, testing several types of models

Rather than picking a model at random, I tested them all to understand their differences.

ModelThe principle
Linear regressionLooks for a formula where each feature adds or subtracts an amount from the price
RidgeThe same idea, but preventing the model from giving too much weight to a single criterion
LassoThe same idea again, but able to completely ignore useless criteria
Random ForestMakes hundreds of "decision trees" vote, each asking a series of questions about the house
XGBoostBuilds trees one after another, each one correcting the mistakes of the previous one

For some models, I also tested different settings, such as the Lasso's selection level or the number and depth of the Random Forest's trees, to find the best version of each.

The shorter the bar, the fewer mistakes the model makes. The Lasso, in green, gets the lowest error. Tree-based models, although more complex, come last.

04The result

The best model is the Lasso. On houses it had never seen, it is off by about 12% on average on the price. It also explains about 91% of the price variations between houses, knowing that a score of 100% would mean it predicts perfectly.

The closer the points are to the dotted line, the more accurate the prediction.

05Step 3, understanding the predictions

A good score isn't enough, I also wanted to know why the model predicts a given price. I used SHAP, a tool that measures the influence of each feature on each prediction. It shows that the model relies on logical criteria, such as the zoning area, the floor area, the year of construction or the overall quality of the house.

Each point represents a house. The further right a point is, the more this feature pushed the predicted price up, and the further left, the more it pushed it down. The color indicates the value of the feature, red when it's high, blue when it's low.

For example, for the ground floor area, the red points are on the right and the blue ones on the left. In other words, the larger the ground floor, the more expensive the model estimates the house, which makes perfect sense.

06What I take away from it

This project taught me that Machine Learning is first and foremost work on data. Cleaning, handling values and preparing the features took me much more time than training the models, and they are what made the difference. I also discovered that a more complex model isn't necessarily better. Once the data was well prepared, a Lasso regression matched much heavier algorithms.

The SHAP analysis showed me the importance of interpretability. A model that predicts well isn't enough, you have to be able to explain its decisions, especially when they concern something as concrete as the price of a house.

This is my first complete Machine Learning project, carried out on my own before starting my Master's degree. Seeing it through, from raw data to explaining the model, gave me confidence in my ability to learn on my own, and the desire to go much further.

07Tech stack

Python, pandas, NumPy, matplotlib, seaborn, scikit-learn (linear regression, Ridge, Lasso, Random Forest), XGBoost and SHAP.