Forum

Notifications
Clear all

Residual Sum of Squares function  

   RSS

0

One of the exercises was to write a function to compute the residual sum of squares. 

I have a few questions:

1. why does the linspace represent the slope? why not np.linspace(0,0.5,200) or np.linspace(0,0.9,700) or any other combination?

2. what does enumerate mean in this context?

# Specify slopes to consider: a_vals
a_vals = np.linspace(0,0.1, 200)

# Initialize sum of square of residuals: rss
rss = np.empty_like(a_vals)

# Compute sum of square of residuals for each value of a_vals
for i, a in enumerate(a_vals):
    rss[i] = np.sum((fertility - a*illiteracy - b)**2)
Share:

Delete your account