code linear regression
How To Code Linear Regression From Scratch -- Quick & Easy!
Here, we load the chocolate data into our program using pandas; we also drop two of the columns we won't be using in our calculation: competitorname and winpercent. Our y becomes the first column in the dataset which indicates if our specific sweet is chocolate (1) or not (0). The remaining columns are used as variables/features to predict our y and, thus, become our X. If you're confused about why we're doing with …[:, 0][:,np.newaxis] on line 5, this is to turn y into a column. We simply add a new dimension to convert the horizontal vector into a vertical column!