Lesson 16: Linear Regression in Python

April 4, 2017 at 11:37 am  •  Posted in s17-busad360 by  •  4 Comments

Tue, Apr 4


  • Sum of Squares Calculations in Python
  • Think Python (PDF)



  • Rewrite the 3 simple regression programs (lesson03a, 3b and 3c) with the following data set
    • Data set 2: {(50,12), (60,15), (70,20), (80,30)}
  • Write 2 programs (one for each of the two data worksheets in this Sheets file) to run multiple regression
    • Use “lesson04_multiregress.py” as example
  • Read Chapter 1 (pp. 1-9) in Think Python
  • Write, from scratch, a simple program to calculate the answer to Exercise 1.4 on p. 9  in Think Python
  • Nothing to submit yet. Instead, just save these programs in your PythonAnywhere “Files”.


  1. Clarissa Mendez / April 4, 2017 at 2:04 pm / Reply

    Hi Professor Holman,

    I ran into issues while trying to run lesson03c.py and lesson04_multiregress.py. The error is coming from us using a newer version of python. The way I got around the error is by writing the following code as the first line of code:


    This allows you to use version 2.7 of python, and runs lesson03c.py and lesson04 without errors.

    • Justin / April 4, 2017 at 3:57 pm / Reply

      Cool, thanks Clarissa! Please remind me to share with students in class on Thursday.

  2. Sheri Romero / April 9, 2017 at 9:16 am / Reply

    Professor Holman,

    Can you check my page on python smedina023, I keep getting ImportError: No module named ‘statsmodels’.

    Thank you,
    Sheri Romero

    • Justin / April 10, 2017 at 2:16 pm / Reply

      Hi Sheri,

      I think this problem can be addressed by Clarissa’s suggestion above. Try to include the text string on line one: #!/usr/bin/python2.7


Leave a Reply