sklearn linear regression



0

Just following the lecture and wondering when we applied linear regression on this example, how do we find the value of price which we were trying to find using Gradient Descent?

shopping_cart = np.array([
    [2, 5, 3, 7, 6],  # Shopper 1
    [0, 6, 2, 0, 3],  # Shopper 2
    [0, 4, 8, 3, 1],  # Shopper 3
    [5, 7, 3, 0, 1],  # Shopper 4
    [9, 3, 7, 2, 0]   # Shopper 5
])  # Independent Variables (Each column is a variable)  # Features - These are the informations based on which I have to find the target
invoices = np.array([97, 43, 62, 64, 73])  # Dependant Variable  # Target Variable - The variable I want to predict for

from sklearn.linear_model import LinearRegression

reg=LinearRegression()

reg.fit(shopping_cart, invoices)  # Train my model now

reg.predict(shopping_cart)

reg.score(shopping_cart, invoices)


2 Answer(s)


0

reg.coef_ contains the prices.


0

Thanks Gagan!