Lesson 16: Linear Regression in Python
April 4, 2017
Tue, Apr 4
Review:
- Sum of Squares Calculations in Python
- Think Python (PDF)
Presentation:
- Linear regression programs (3 methods)
- Multiple regression program
Assignment:
- 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”.
4 Comments
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:
#!/usr/bin/python2.7
This allows you to use version 2.7 of python, and runs lesson03c.py and lesson04 without errors.
Cool, thanks Clarissa! Please remind me to share with students in class on Thursday.
Professor Holman,
Can you check my page on python smedina023, I keep getting ImportError: No module named ‘statsmodels’.
Thank you,
Sheri Romero
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
Best,
JH