Practical Regression Model Comparison in Python

This project focuses on the practical comparison of supervised machine learning regression models using Python.

The aim was not only to identify strong-performing models, but also to understand how different regression algorithms behave when applied to the same real-world prediction task, and how performance, speed, complexity, prediction behaviour and usability influence practical model selection.

Featured Project: Predicting Diamond Prices

The project uses structured diamond data to compare a wide range of regression algorithms for predicting diamond prices.

Each model was tested using a consistent machine learning workflow so that results could be compared fairly across different model families.

The comparison includes baseline models, linear models, regularised models, tree-based models, ensemble methods, boosting algorithms and other supervised regression approaches.

Rather than focusing only on predictive performance, the project also examines practical considerations such as runtime, model size, prediction behaviour and overall suitability for real-world use.

Comparison of tuned regression models based on RMSE. Lower values indicate better predictive performance.

What the Project Includes

The project demonstrates a complete supervised regression workflow, including:

Model Comparison Approach

A consistent experimental structure was used across the different regression models.

Models were first trained and evaluated using the same prepared dataset and comparable evaluation procedures. Selected models were then further investigated through cross-validation and hyperparameter tuning before final evaluation on the test data.

The results were compared from several perspectives rather than relying on a single performance score.

This makes it possible to examine the trade-offs between predictive performance, computational efficiency, model complexity and practical usability.

Detailed comparison of training, tuned and final test performance, together with training and prediction times.

Practical comparison of regression models across performance, speed, memory efficiency, robustness and implementation requirements.

Visual Model Comparison

Visual analysis was used to compare how closely each tuned regression model reproduced the actual diamond prices and to identify differences in prediction behaviour between model families.

Actual versus predicted values for all tuned regression models. Predictions closer to the diagonal reference line indicate better agreement with the true values.


Residual plots were used to examine prediction errors and identify patterns that may indicate bias, non-linearity or changing error variance across the models.

Residual plots for all tuned regression models, showing the pattern and spread of prediction errors.


Residual distributions were analysed to compare the concentration, spread and shape of prediction errors across the tuned regression models.

Residual error distributions for all tuned regression models, showing how prediction errors are distributed around zero.

Best Model Analysis: Stacking Regressor


Following the model comparison, the Stacking Regressor was selected for more detailed analysis based on its strong overall predictive performance. Its predictions, residuals, error distribution and feature importance were examined in greater detail.

Actual versus predicted values for the Stacking Regressor. Points closer to the diagonal reference line indicate more accurate predictions.


The residual plot was used to examine how prediction errors change across the predicted price range and to identify any systematic patterns.

Residual plot for the Stacking Regressor. A balanced spread around zero indicates more consistent prediction behaviour.


The residual distribution was analysed to assess how closely prediction errors were centred around zero and how widely those errors were spread.

Residual distribution for the Stacking Regressor, showing the frequency and spread of prediction errors around zero.


Permutation importance was used to estimate how strongly each feature contributed to the Stacking Regressor’s predictive performance.

Permutation importance for the Stacking Regressor, showing the relative influence of the input features on model performance.


Prediction Behaviour

Prediction behaviour was examined using selected test samples to compare the actual diamond prices with the values predicted by different regression models.

Comparison of actual and predicted prices for selected test samples across the regression models.


Prediction ranges were compared to examine how closely each model reproduced the overall spread of diamond prices and where systematic differences appeared.

Summary of predicted price ranges and their differences compared with the actual target values.


The best-performing model was also evaluated across different diamond price ranges to identify where prediction errors increased and whether performance remained consistent across lower- and higher-value samples.

Performance of the Stacking Regressor across different diamond price ranges, highlighting changes in prediction error across the target range.


Model Family Comparison

Predicted price distributions were compared across different regression model families to examine how closely each group reproduced the overall distribution of the actual target values.

Comparison of actual and predicted price distributions across regression model families.

Why I Built This Project

I built this project to go beyond training a single machine learning algorithm and develop a deeper understanding of regression model behaviour.

Testing a broad range of models on the same prediction problem made it easier to see how different algorithm families respond to the same data and how model selection changes depending on the criteria being considered.

The project reinforced an important practical lesson: the best-performing model is not automatically the best model for every situation.

A useful model also needs to be reliable, efficient and appropriate for the intended application.

Key Skills Demonstrated

This project demonstrates skills in:

  • Python programming
  • pandas
  • NumPy
  • scikit-learn
  • supervised machine learning
  • regression modelling
  • data preprocessing
  • model evaluation
  • cross-validation
  • hyperparameter tuning
  • model comparison
  • performance analysis
  • runtime analysis
  • data visualisation
  • practical model selection
  • technical documentation
  • GitHub project presentation

What I Learned

Through this project, I developed a stronger understanding of the complete regression modelling workflow and the differences between major regression model families.

I also gained practical experience in comparing models beyond headline performance scores, including their computational requirements, prediction behaviour and suitability for different use cases.

The project helped me improve my Python workflow, experimental structure, data visualisation, technical documentation and ability to communicate machine learning results clearly.