Predicting Concrete Strength with Deep Learning: From Regression to Classification
Can we predict the strength of concrete without spending days testing every sample in a laboratory?
Maybe.
In this project, I started with a simple question:
Can we predict the compressive strength of concrete using its mixture components and age?
Then I took it one step further:
Can a neural network also determine which strength class a concrete mixture belongs to?
To explore these questions, I worked with the same dataset using two different approaches:
- Regression β predicting the actual compressive strength in MPa
- Classification β predicting the concreteβs strength category
The results were a great opportunity to see both the potential and the limitations of Deep Learning on tabular data.
π The Dataset
The dataset contains 1,030 concrete samples.
Each sample includes information about:
- Cement
- Blast Furnace Slag
- Fly Ash
- Water
- Superplasticizer
- Coarse Aggregate
- Fine Aggregate
- Age
The original target variable is:
Concrete Compressive Strength (MPa)
So the basic problem looks like this:
Concrete Mix + Age
β
Neural Network
β
Concrete Strength (MPa)Part 1 β Regression
I first treated the problem as a regression task.
The goal was straightforward:
Given the concrete mixture and its age, predict its compressive strength as a continuous value.
For example, the model might predict:
42.7 MParather than a category.
The First Neural Network
I initially experimented with a larger neural network.
However, the training and validation loss showed a clear gap. The model was learning the training data extremely well but was not generalizing as effectively to unseen data.
This was an important lesson:
A bigger neural network does not automatically mean a better neural network.
I simplified the architecture and obtained a much healthier training/validation behavior.
The final regression architecture was based on:
Input
β
Dense(64) + ReLU
β
Dense(32) + ReLU
β
Dense(16) + ReLU
β
Dense(9) + ReLU
β
Dense(1)The model used:
- Adam optimizer
- Mean Squared Error (MSE)
- ReLU activation functions in hidden layers
Since this was a regression problem, the output layer did not use an activation function.
From Regression to Classification
After predicting the actual strength value, I wanted to ask a different question:
What if we donβt need the exact MPa value? What if we only need to know the strength category?
I converted the continuous Strength variable into four categories:
StrengthConcrete Class< 17 MPanon-structural17 β <28 MParesidential28 β <70 MPacommercialβ₯ 70 MPahigh-strength
Now the problem changed from:
Predict 43.7 MPato:
Predict β commercialThis transformed the problem into a multi-class classification task.
Feature Engineering
I also created additional categorical features.
One of them was Green, which was created using the Slag, Fly Ash, and Superplasticizer values according to predefined criteria.
I also converted the numerical Superplasticizer variable into:
yes
noThis allowed the model to work with categorical information as well as the original numerical features.
Categorical input variables were then converted into numerical representations using:
x = pd.get_dummies(x, drop_first=True)The input features were scaled using:
scaler = StandardScaler()Avoiding Data Leakage
There was an important detail in this transformation.
The ConcreteClass target was created directly from Strength.
Therefore, keeping Strength as an input feature would essentially give the model the answer beforehand.
That would create data leakage.
So I removed it:
df.drop("Strength", axis=1, inplace=True)This means the classification model has to learn the relationship from the actual concrete mixture and age instead of simply reading the original strength value.
Deep Learning Classification
The classification model was designed as a simpler neural network:
Input
β
Dense(64) + ReLU
β
Dense(32) + ReLU
β
Dense(16) + ReLU
β
Dense(4) + Softmax
β
ConcreteClassThe model used:
- Adam optimizer
- Sparse Categorical Crossentropy
- Accuracy as the evaluation metric
- ReLU in hidden layers
- Softmax in the output layer
The four classes were encoded as:
commercial β 0
high-strength β 1
non-structural β 2
residential β 3The Result
The classification model achieved:
π― 94.66% Test Accuracy
This means that the model correctly classified approximately 94.66% of previously unseen test samples.
What I found particularly interesting was the relationship between training and validation accuracy.
Get Saliha Dilβs stories inΒ yourΒ inbox
Join Medium for free to get updates fromΒ thisΒ writer.
The two curves remained relatively close instead of separating dramatically.
That suggests the model was not simply memorizing the training data.
Looking Beyond Accuracy
Accuracy alone doesnβt tell the whole story.
So I also created a Confusion Matrix to see which concrete classes the model could distinguish well and which ones caused problems.
The model performed particularly well on:
- π’
commercial - π’
residential - π’
non-structural
The model struggled more with:
- π‘
high-strength
One reason is that the high-strength category contains far fewer samples than the other categories.
This is an important reminder:
A high overall accuracy does not necessarily mean that every class is being predicted equally well.
Is Deep Learning Better Than Classical Machine Learning?
This is where I want to be careful.
This project does not prove that Deep Learning is universally better than classical Machine Learning.
I did not perform a direct benchmark against models such as:
- Random Forest
- XGBoost
- Support Vector Machines
- Linear Regression
using exactly the same experimental setup.
So it would be misleading to claim:
βDeep Learning is always better.β
Instead, this project demonstrates something more specific:
A neural network can learn surprisingly complex relationships from concrete mixture data and achieve strong classification performance, even on a relatively small tabular dataset.
And that is what makes Deep Learning interesting.
Why Is Deep Learning So Powerful?
One of the most fascinating aspects of neural networks is that we donβt have to manually define every relationship between variables.
We give the model information such as:
Cement
Water
Fly Ash
Slag
Aggregates
Age
...and the network learns its internal representations through its weights.
We donβt explicitly tell it:
βWater interacts with cement in this particular way.β
Instead, the model tries to discover useful patterns during training.
This becomes especially interesting as problems become more complex.
What About Big Data?
There is an important distinction here.
This dataset contains 1,030 samples, so it would not be accurate to call it a βBig Dataβ problem.
The real strength of Deep Learning becomes much more apparent when dealing with large and high-dimensional datasets such as:
- Images
- Video
- Audio
- Natural language
- Time series
- Sensor data
As the amount and complexity of data increase, manually designing all useful features becomes increasingly difficult.
Deep Learning can learn representations directly from the data.
That is one of the major reasons neural networks have become so powerful in fields such as computer vision and natural language processing.
What This Project Taught Me
This project was not simply about getting a high accuracy score.
It taught me several important lessons.
1. Bigger isnβt always better
My initial larger network showed signs of overfitting.
Reducing the model complexity produced a healthier learning process.
2. Preprocessing matters
Scaling, categorical encoding, feature engineering, and train/test splitting are not minor details.
They are fundamental parts of the model.
3. Data leakage can completely change your results
If I had left Strength inside the input features after using it to create ConcreteClass, the model could have effectively seen the answer.
4. Accuracy isnβt everything
The confusion matrix revealed that the model performs differently across classes.
5. Deep Learning is not magic
A neural network is not automatically good simply because it has many layers.
The architecture, data, preprocessing, target definition, and evaluation strategy all matter.
Whatβs Next?
The next experiment I would like to run is a direct comparison between classical Machine Learning and Deep Learning.
For example:
Concrete Dataset
β
ββββββββββββββββ΄βββββββββββββββ
β β
Classical ML Deep Learning
β β
Random Forest Neural Network
XGBoost β
SVM β
ββββββββββββββββ¬βββββββββββββββ
β
Compare ResultsFor regression:
- RMSE
- MAE
- RΒ²
For classification:
- Accuracy
- Precision
- Recall
- F1-score
That would allow us to answer a much more interesting question:
When does Deep Learning actually outperform classical Machine Learning on tabular data?
Final Thoughts
What started as a simple question β
βCan I predict concrete strength?β
β turned into a much broader exploration of machine learning.
I trained a neural network to predict a continuous physical property, transformed the same problem into a classification task, engineered new features, dealt with categorical variables, prevented data leakage, evaluated the model with accuracy and a confusion matrix, and achieved 94.66% test accuracy on the classification task.
But perhaps the most important lesson was not the accuracy score.
It was understanding why the model worked, where it failed, and what the data was actually telling me.
Thatβs what makes Deep Learning so exciting to me.
Not simply that a model can produce a prediction β
but that, with enough data and the right architecture, we can teach a machine to discover patterns that we never explicitly programmed into it.
And thatβs where the real power begins.








