This project was created by Nowa Analytics.
This project demonstrates the development of a neural network regression model using the Keras library to predict the compressive strength of concrete. The primary goal is to build, train, and evaluate a model based on the ingredients used in the concrete mixture and the age of the sample.
The project walks through the essential steps of a machine learning workflow, including:
- Loading and inspecting the dataset.
- Preprocessing and cleaning the data.
- Defining and compiling a neural network architecture.
- Training the model and evaluating its performance using the mean squared error metric.
- Repeating the training and evaluation process multiple times to assess the model's stability and report the mean and standard deviation of its performance.
The model is trained on the Concrete Compressive Strength dataset, which contains various samples of concrete and their measured compressive strength.
The features (predictors) used to train the model are the quantities of each ingredient in the concrete mixture, measured in kg/m^3, and the age of the concrete. The target variable is the concrete's compressive strength.
Predictor Variables:
- Cement
- Blast Furnace Slag
- Fly Ash
- Water
- Superplasticizer
- Coarse Aggregate
- Fine Aggregate
- Age (in days)
Target Variable:
- Strength (compressive strength in megapascals, MPa)
The dataset consists of 1030 instances with no missing values, making it a clean dataset suitable for immediate model building.
This project requires the following Python libraries:
- pandas: For data manipulation and analysis.
- numpy: For numerical operations.
- scikit-learn: For splitting the data and calculating the mean squared error.
- Keras: For building and training the neural network.
- TensorFlow: As the backend for Keras.
The project follows a systematic approach to building and evaluating the regression model.
- The dataset (
concrete_data.csv) is loaded into a pandas DataFrame. - The data is checked for missing values and general statistics are reviewed using
describe(). - The dataset is split into predictor variables (features) and the target variable (
Strength).
A sequential neural network is defined with the following structure:
- Input Layer: An input shape corresponding to the number of predictor variables (8 features).
- Hidden Layer: One hidden layer with 10 neurons and a ReLU (
relu) activation function. - Output Layer: A single neuron to output the predicted continuous value for concrete strength.
The model is compiled using:
- Optimizer: Adam (
adam), an efficient stochastic gradient descent algorithm. - Loss Function: Mean Squared Error (
mean_squared_error), which is standard for regression tasks.
The core of the project involves training and evaluating the model 50 times to ensure the results are robust and not dependent on a single random split of the data.
For each of the 50 iterations:
- The data is randomly split into a training set (70%) and a testing set (30%).
- The model is trained on the training data for 50 epochs.
- After training, the model's performance is evaluated on the unseen test data.
- The Mean Squared Error (MSE) between the predicted and actual strength values is calculated and stored.
After completing all 50 iterations, the list of recorded Mean Squared Errors is analyzed to determine the model's overall performance and consistency. The final output includes:
- Mean of the 50 Mean Squared Errors.
- Standard Deviation of the 50 Mean Squared Errors.
Based on the provided notebook, the final results were:
- Mean MSE: 47.05
- Standard Deviation of MSE: 4.15