Introduction to the Course

Introduction to Linear Modeling in Python

Jason Vestuto

Data Scientist

Introduction to Chapter 1

Chapter Roadmap:

  • Motivating Examples
  • Data Visualization
  • Descriptive Statistics
Introduction to Linear Modeling in Python

Example Trip Data

Plot of points, Distance versus Time, miles versus hours

Introduction to Linear Modeling in Python

Models as Descriptions

# Range of y data, in miles
y_range = np.max(y) - np.min(y) = 300 - 0 = 300
# Range of x data, in hours
x_range = np.max(x) - np.min(x) = 6 - 0 = 6
# Estimating the speed
mph = y_range / x_range = 300 / 6 = 50
Introduction to Linear Modeling in Python

Visualizing a Model

Plot of data and model, distance versus time

Introduction to Linear Modeling in Python

Model Predictions

# Model as python expression
miles = 50*hours
# Model predicts distance is 300 miles at 6 hours
time = 6
distance = 50 * time = 50 * 6 = 300
def model(time):
    return 50*time

predicted_distance = model(time=10)
Introduction to Linear Modeling in Python

Interpolation

Plot of distance versus time, with interpolation point marked between two data points

Introduction to Linear Modeling in Python

Extrapolation

Plot of distance versus time, with extrapolation point marked outside data points at greater time

Introduction to Linear Modeling in Python

Let's practice!

Introduction to Linear Modeling in Python

Preparing Video For Download...