Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Concrete Compressive Strength Prediction

Linear Regression vs Ridge Regression in R


Overview

This project analyses the UCI Concrete Compressive Strength dataset to predict the compressive strength of concrete mixtures (measured in MPa) from their ingredient composition and curing age.

Two regression models are built and compared:

  • Ordinary Least Squares (OLS) Linear Regression — baseline model
  • Ridge Regression (L2 Regularisation) — regularised alternative to address multicollinearity

The project covers the full data science pipeline: exploratory analysis, visualisation, correlation analysis, model training, cross-validation for hyperparameter tuning, and test-set evaluation.


Dataset

Property Detail
Source UCI Machine Learning Repository – Concrete Compressive Strength
Observations 1,030
Features 8 continuous (cement, blast furnace slag, fly ash, water, superplasticiser, coarse aggregate, fine aggregate, age) + 2 engineered (concrete category, fly ash flag)
Target CompressiveStrength (MPa)

Key Findings

Metric Linear Regression Ridge Regression
Test RMSE (MPa) ~10.4 ~10.2
Notes Baseline OLS L2 regularisation with λ tuned via 10-fold CV
  • Cement content showed the strongest positive correlation with compressive strength (r ≈ 0.50)
  • Water content showed a consistent negative relationship with strength
  • Curing age is a significant predictor — older mixtures are substantially stronger
  • Fly ash presence had a measurable but modest impact on strength
  • Ridge regression provided marginal improvement, suggesting mild multicollinearity in the feature set
  • Optimal lambda (λ) selected by cross-validation minimised mean squared error without over-shrinking informative predictors

⚠️ Results above are indicative based on published benchmarks for this dataset. Run srs/analysis.R to reproduce exact figures.


Visualisations

Plot Description
strength_distribution.png Distribution of the target variable (right-skewed)
strength_by_category.png Compressive strength variation across concrete categories
cement_vs_strength.png Positive relationship between cement content and strength
water_vs_strength.png Negative relationship between water content and strength
flyash_effect.png Effect of fly ash inclusion on strength
correlation_matrix.png Full pairwise correlation heatmap (all numeric features)
ridge_cv_plot.png Cross-validation MSE across lambda values (ridge tuning)

All plots are saved in the visuals/ directory.


Project Structure

├── srs/
│   └── analysis.R          # Full analysis script (EDA → modelling → evaluation)
├── visuals/
│   ├── cement_vs_strength.png
│   ├── correlation_matrix.png
│   ├── flyash_effect.png
│   ├── ridge_cv_plot.png
│   ├── strength_by_category.png
│   ├── strength_distribution.png
│   └── water_vs_strength.png
├── data/
│   └── concrete compressive strength.xlsx   # Source dataset (not tracked in repo)
└── README.md

How to Run

Prerequisites

Install the required R packages:

install.packages(c("tidyverse", "readxl", "caret", "glmnet", "corrplot"))

Steps

  1. Clone the repository:

    git clone https://github.com/iamittiwariji/Concrete-Strength-Prediction-Using-Linear-and-Ridge-Regression-R-.git
  2. Place the dataset at data/concrete compressive strength.xlsx (Source: UCI Repository)

  3. Open and run srs/analysis.R in RStudio or from the command line:

    Rscript srs/analysis.R

Output plots will be saved to the visuals/ directory. Model metrics will be printed to the console.


Methods

Exploratory Data Analysis

  • Summary statistics (mean, standard deviation) for all predictors and the target
  • Distribution plots and boxplots by concrete category
  • Scatterplots for key ingredient-strength relationships

Correlation Analysis

  • Full correlation matrix computed across all numeric variables
  • Pairs with |r| > 0.7 flagged for potential multicollinearity
  • Visualised using corrplot with annotated coefficients

Modelling

Linear Regression (OLS)

  • Trained using lm() on all available features
  • 80/20 train-test split (set.seed(123) for reproducibility)
  • Evaluated on held-out test set using RMSE

Ridge Regression

  • Feature matrix prepared using model.matrix() (handles factor encoding automatically)
  • Optimal λ selected via 10-fold cross-validation with cv.glmnet(alpha = 0)
  • Final model fitted at lambda.min and evaluated on the same test set
  • Coefficient paths plotted across the full lambda range

Technologies

R · tidyverse · ggplot2 · glmnet · caret · corrplot · readxl


Skills Demonstrated

  • Regression modelling (OLS and L2 regularisation)
  • Hyperparameter tuning via cross-validation
  • Multicollinearity detection and handling
  • Data visualisation with ggplot2
  • Reproducible analytical workflow in R

Author

Amit Tiwari MSc Data Science, University of Salford (2025)

LinkedIn · GitHub

About

This project presents a predictive analysis of concrete compressive strength using multiple linear regression and ridge regression in R. The objective is to understand how concrete mix composition and curing age influence strength, and to compare a baseline regression model with a regularised alternative.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages