Added weight report and more comments.
This commit is contained in:
parent
c81789fbd3
commit
6922a8e6cb
4 changed files with 22 additions and 6 deletions
|
|
@ -74,7 +74,7 @@ class LinearRegression:
|
|||
# makes Y prediction value for X batch value by multiplying X and weight vectors.
|
||||
|
||||
error = y_batch - y_pred # error is difference between Y batch value and Y prediction value
|
||||
grad = -2 * x_batch.T.dot(error) / batch_size
|
||||
grad = -2 * x_batch.T.dot(error) / batch_size # for linear regression -2*X^T*(error)
|
||||
# gradient is calculated by multiplication of error, transposed X batch value and -2 divided by batch size
|
||||
|
||||
w_np -= self.lr * grad # weight is decreased by multiplication of learning rate and gradient
|
||||
|
|
@ -169,4 +169,8 @@ if __name__ == "__main__":
|
|||
# predict Y values using the trained data
|
||||
preds = model.predict(x_test)
|
||||
print("\nFirst 10 predictions:")
|
||||
print(preds.head(10))
|
||||
print(preds.head(10))
|
||||
|
||||
# weight report
|
||||
print("\nWeights from the model:")
|
||||
print(model.w)
|
||||
Loading…
Add table
Add a link
Reference in a new issue