When we have implemented multiple regression in our code, we’ve used a sample input of a house which is 1200 sqft, 3 bedrooms, 1 floor, 40 years old. (Code taken from Lab3)
We’ve implemented it like this and we got the output - $318709.09
x_house = np.array([1200, 3, 1, 40])
x_house_norm = (x_house - X_mu) / X_sigma
print(x_house_norm)
x_house_predict = np.dot(x_house_norm, w_norm) + b_norm
print(f" predicted price of a house with 1200 sqft, 3 bedrooms, 1 floor, 40 years old = ${x_house_predict*1000:0.0f}")
Similarly when we’re using a linear regressor from scikit learn we’ve used very similar code( albeit without normalisation) and the solution we got was the same as that of the above - $318709.09 (Code taken from Lab 6)
x_house = np.array([1200, 3,1, 40]).reshape(-1,4)
x_house_predict = linear_model.predict(x_house)
print(f" predicted price of a house with 1200 sqft, 3 bedrooms, 1 floor, 40 years old = ${x_house_predict*1000}")
How do we do this with SGDRegression? The following is the code I tried using, however it’s giving a very erroneous answer of - $363139.3. (Trying to execute code in Lab 5)
x_house = np.array([1200, 3,1, 40]).reshape(-1,4)
x_house_norm = scaler.fit_transform(x_house)
x_house_predict = sgdr.predict(x_house_norm)
print(x_house_predict*1000)
I believe I’m making an error in normalisation, but I don’t know how to fix it