Hello Students:
Start by downloading HW1.ipynb from this folder. Then develop it into your solution.
Write code where you see "... your code here ..." below. (You are welcome to use more than one cell.)
I've included the output from my solution in HW1.html so you can check your work. Your output should match or be close to mine. Use 3 significant figures for floats. e.g. We can print 3 figures for 𝜋/1000 as print(f'{np.pi/1000:.3}'). The pattern is print(f'{x:.precision}'), where x is the value to print and precision is the number of figures.
If you have questions, please ask them in class or office hours. Our TA and I are very happy to help with the programming (provided you start early enough, and provided we are not helping so much that we undermine your learning).
Please clean up your code:
When you are done, run these Notebook commands:
Turn in:
As a check, download your HW01.ipynb from Canvas to a new 'junk' folder. Try 'Kernel > Restart and Run All' to make sure it works. Glance through the new '.html' file.
Turn in partial solutions to Canvas before the deadline. e.g. Turn in part 1, then parts 1 and 2a, then your whole solution. That way we can award partial credit even if you miss the deadline. We will grade your last submission before the deadline.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn import svm, linear_model
to classify cars as having automatic or manual transmissions.
# ... your code here ...
The decision boundary is -8.24 * weight + -0.309 * mileage + 32.0 = 0. The training accuracy is 1.0. We predict that a car weighing 20 thousand pounds that gets 20 mpg has transmission type 0 (where 0=automatic, 1=manual).
Use the matrix formula $w = (X^T X)^{-1} X^T y$ we developed in class to fit these three points: (0, 5), (2, 1), (4, 3). (Use linear_model.linearRegression(), if you wish, to check your work.)
... your answer here (just give the model, $y = w x + b$; you do not need to show your work) ...
intercept=4.0, slope=-0.5
Estimate the average daily trading volume of a Dow Jones Industrial Average stock from its market capitalization. That is, use $y = $ AvgVol vs. $x =$ MarketCap.
# ... your code here ...
The model is Volume = 2.68e-05 * (Market Capitalization) + 3.41e+06. R^2 is 0.705. We predict a Volume of 1.01e+07 for a company with Market Capitalization 2.5e+11 (see red dot).
Estimate the same volume from both market capitalization and price. That is, use $y =$ AvgVol vs. $x_1 =$ MarketCap and $x_2 =$ Price.
# ... your code here ...
The model is Volume = 2.89e-05 * (Market Capitalization) + -6.69e+04 * Price + 1.44e+07. R^2 is 0.823.