Skip to content
0

Can you predict the strength of concrete?

๐Ÿ“– Background

You work in the civil engineering department of a major university. You are part of a project testing the strength of concrete samples.

Concrete is the most widely used building material in the world. It is a mix of cement and water with gravel and sand. It can also include other materials like fly ash, blast furnace slag, and additives.

The compressive strength of concrete is a function of components and age, so your team is testing different combinations of ingredients at different time intervals.

The project leader asked you to find a simple way to estimate strength so that students can predict how a particular sample is expected to perform.

๐Ÿ’พ The data

The team has already tested more than a thousand samples (source):

Compressive strength data:
  • "cement" - Portland cement in kg/m3
  • "slag" - Blast furnace slag in kg/m3
  • "fly_ash" - Fly ash in kg/m3
  • "water" - Water in liters/m3
  • "superplasticizer" - Superplasticizer additive in kg/m3
  • "coarse_aggregate" - Coarse aggregate (gravel) in kg/m3
  • "fine_aggregate" - Fine aggregate (sand) in kg/m3
  • "age" - Age of the sample in days
  • "strength" - Concrete compressive strength in megapascals (MPa)

Acknowledgments: I-Cheng Yeh, "Modeling of strength of high-performance concrete using artificial neural networks," Cement and Concrete Research, Vol. 28, No. 12, pp. 1797-1808 (1998).

Import the required libraries:

#import the required libraries:

import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib as mpl
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
import statsmodels.api as sm
from sklearn.metrics import confusion_matrix, accuracy_score

Load the data and inspect the first five columns:

df = pd.read_csv('data/concrete_data.csv')
df.head()

Exploratory Data Analysis

Check the value counts for age, since one of the requriements is to find the average strength for cure times of 1, 7, 14, and 28 days.

df['age'].value_counts()
df.shape

Create a function to calculate the average strength of concreate at ages 1, 7 14, and 28 days:

#Function to calculate the avg strength after days curing:
def avg_strength (x, y):
    strength1 = df[df[x]==y]
    avg = strength1['strength'].mean()
    return avg

1 Day:

print('The average strength after one day is', round(avg_strength('age', 1), 2), 'MPa')
print('The average strength after seven days is', round(avg_strength('age', 7), 2), 'MPa')
print('The average strength after fourteen days is', round(avg_strength('age', 14), 2), 'MPa')
โ€Œ
โ€Œ
โ€Œ