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.
| 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) |
| 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. Runsrs/analysis.Rto reproduce exact figures.
| 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.
├── 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
Install the required R packages:
install.packages(c("tidyverse", "readxl", "caret", "glmnet", "corrplot"))-
Clone the repository:
git clone https://github.com/iamittiwariji/Concrete-Strength-Prediction-Using-Linear-and-Ridge-Regression-R-.git
-
Place the dataset at
data/concrete compressive strength.xlsx(Source: UCI Repository) -
Open and run
srs/analysis.Rin 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.
- Summary statistics (mean, standard deviation) for all predictors and the target
- Distribution plots and boxplots by concrete category
- Scatterplots for key ingredient-strength relationships
- Full correlation matrix computed across all numeric variables
- Pairs with |r| > 0.7 flagged for potential multicollinearity
- Visualised using
corrplotwith annotated coefficients
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.minand evaluated on the same test set - Coefficient paths plotted across the full lambda range
R · tidyverse · ggplot2 · glmnet · caret · corrplot · readxl
- Regression modelling (OLS and L2 regularisation)
- Hyperparameter tuning via cross-validation
- Multicollinearity detection and handling
- Data visualisation with ggplot2
- Reproducible analytical workflow in R
Amit Tiwari MSc Data Science, University of Salford (2025)