Visualisera linjära samband

Introduktion till linjär modellering i Python

Jason Vestuto

Data Scientist

Snabbdiagram

import matplotlib.pyplot as plt
plt.plot(x, y, 'r-o')
plt.show()

Introduktion till linjär modellering i Python

Objektgränssnitt

# Import the pyplot module
import matplotlib.pyplot as plt
# Create figure and axis objects
fig, axis = plt.subplots()
# Prepare initial style options
options = dict(marker='o', color='blue')
Introduktion till linjär modellering i Python

Objektgränssnitt

# Call the plot method on the axis object
line = axis.plot(x, y, **options)
# Modify the axis object with set methods
_ = axis.set_ylabel('Times')
_ = axis.set_xlabel('Distances')
# Display figure
plt.show()
Introduktion till linjär modellering i Python

Visualisera linjära data

  • två punkter:
    • (x1,y1) = (0,0)
    • (x2,y2) = (2,3)
  • förändring i x och y:
    • dy = (y2 - y1) = 3 - 0
    • dx = (x2 - x1) = 2 - 0
  • lutning = stigning dividerat med löplängd
    • slope = dy/dx = 3/2
  • skärningspunkt:
    • när x=0: y1 = 0

Diagram som illustrerar stigning och löplängd för att visa lutning

Introduktion till linjär modellering i Python

Nu kör vi en övning!

Introduktion till linjär modellering i Python

Preparing Video For Download...