Learn practical skills, build real-world projects, and advance your career
Created 4 years ago
Linear Regresion with PyTorch
The dataset selected for this notebook is the Titanic dataset.
This dataset has several information where each row represents one person. The columns describe different attributes about the person including whether they survived, their age, their passenger-class, their sex, and the fare they paid. Finally the dataset is devided in training and evaluation data.
The training and evaluation data can be found in the following links:
- Training data: https://storage.googleapis.com/tf-datasets/titanic/train.csv
- Evaluation data: https://storage.googleapis.com/tf-datasets/titanic/eval.csv
This notebook is focused in the prediction of wheather a passenger survived or not, and it is build based on the following steps:
- Install depencies
- Import modules
- Download and dataset analysis
- Preparing the dataset for training
- Creating a Linear Regression model
- Training the model and fitting the data
- Making predictions using the trained model
- Saving the model
- Commiting and uploading the notebook
This notebook is based on the concepts from the first two lectures and as part of the Assignment 2 of the course Deep Learning with PyTorch, which you can find in the following links:
- Assignment 2 - Linear Regression: click here
- Lecture 1: click here
- Lecture 2: click here
- PyTorch basics: https://jovian.ml/aakashns/01-pytorch-basics
- Linear Regression: https://jovian.ml/aakashns/02-linear-regression
- Logistic Regression: https://jovian.ml/aakashns/03-logistic-regression
- Linear regression (minimal): https://jovian.ml/aakashns/housing-linear-minimal
- Logistic regression (minimal): https://jovian.ml/aakashns/mnist-logistic-minimal
Step 1: Install dependencies
# Uncomment and run the commands below if imports fail
# !conda install numpy pytorch torchvision cpuonly -c pytorch -y
# !pip install matplotlib --upgrade --quiet
!pip install jovian --upgrade --quiet
|████████████████████████████████| 92kB 2.4MB/s eta 0:00:011
Building wheel for uuid (setup.py) ... done
Step 2: Import Modules
import torch
import jovian
import torchvision
import torch.nn as nn
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import torch.nn.functional as F
from torchvision.datasets.utils import download_url
from torch.utils.data import DataLoader, TensorDataset, random_split
/usr/local/lib/python3.6/dist-packages/statsmodels/tools/_testing.py:19: FutureWarning: pandas.util.testing is deprecated. Use the functions in the public API at pandas.testing instead.
import pandas.util.testing as tm