Added weight report and more comments.

This commit is contained in:
Batuhan Berk Başoğlu 2025-09-22 18:01:29 -04:00
parent c81789fbd3
commit 6922a8e6cb
Signed by: batuhan-basoglu
SSH key fingerprint: SHA256:kEsnuHX+qbwhxSAXPUQ4ox535wFHu/hIRaa53FzxRpo
4 changed files with 22 additions and 6 deletions

View file

@ -74,7 +74,7 @@ class LogisticRegression:
z = self.x.dot(self.w) # linear prediction
p = self.sigmoid(z) # probabilities of the model predictions
gradient = self.x.T.dot(p - self.y) / self.y.size # gradient calculation formula
gradient = self.x.T.dot(p - self.y) / self.y.size # for logistic regression X^T*(p - y)
self.w -= self.lr * gradient # gradient multiplied by learning rate is removed from weight
@ -190,4 +190,8 @@ if __name__ == "__main__":
# predict Y values using the trained data
first_10 = X_test[:10]
y_hat = model.predict(first_10)
print("\nFirst 10 predictions:", y_hat.ravel())
print("\nFirst 10 predictions:", y_hat.ravel())
# weight report
print("\nWeights from the model:")
print(model.w)