Learn practical skills, build real-world projects, and advance your career

Concrete Compressive Strength prediction using linear regression

In this assignment we're going to use information like Cement (component 1)(kg in a m^3 mixture), Blast Furnace Slag (component 2)(kg in a m^3 mixture), Fly Ash (component 3)(kg in a m^3 mixture), Water (component 4)(kg in a m^3 mixture), Superplasticizer (component 5)(kg in a m^3 mixture), Coarse Aggregate (component 6)(kg in a m^3 mixture), Fine Aggregate (component 7)(kg in a m^3 mixture), Age (day) to predict the Compressive strength of cement (in megapascals). This kind of model can be useful for construction companies to determine the compressive strength for various grades of cement. The dataset for this problem is taken from: https://archive.ics.uci.edu/ml/datasets/Concrete+Compressive+Strength

We will create a model with the following steps:

  1. Download and explore the dataset
  2. Prepare the dataset for training
  3. Create a linear regression model
  4. Train the model to fit the data
  5. Make predictions using the trained model
# Uncomment and run the commands below if imports fail
#!conda install pytorch cpuonly -c pytorch -y
#!conda install numpy pytorch torchvision cpuonly -c pytorch -y
#!pip install jovian --upgrade --quiet
# !pip install matplotlib --upgrade --quiet
import torch
import jovian
import torchvision
import torch.nn as nn
import pandas as pd
import matplotlib.pyplot as plt
import torch.nn.functional as F
from torchvision.datasets.utils import download_url
from torch.utils.data import DataLoader, TensorDataset, random_split
project_name='Concrete-Compressive-Strength' # will be used by jovian.commit

Step 1: Download and explore the data

Download the data from https://archive.ics.uci.edu/ml/machine-learning-databases/concrete/compressive/Concrete_Data.xls
and save the file as .csv to change the file format.