I am trying to use Logistic Regression to make a spam filter, but I am having trouble understanding the weight update part. I have processed my email dataset, and I have an attribute vector of the top n words that are most likely to be contained within a spam.

From my understanding, during training, I will have to implement an optimization formula after each training example in order to update the weights.

$$ w_l \leftarrow w_l + \eta \cdot \sum_{i=1}^m [ y^{(i)} - P(c_+ \mid \vec{x}^{(i)} )] \cdot x_l^{(i)} $$

How does a formula such as this work? How can it be implemented in Python?


I think i found out how that works, so i made a short article about it . https://medium.com/@kourloskostas/python-spam-filter-86b21d7d1564 I hope it helps!

| improve this answer | |
  • 2
    $\begingroup$ While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review $\endgroup$ – DuttaA Apr 14 at 8:38
  • 2
    $\begingroup$ You are right ,will post the answer here as well $\endgroup$ – kostas Apr 14 at 9:50
  • $\begingroup$ Actually, if you could excerpt the most salient passages from the medium article, that would really help with this answer, specifically. (Welcome to SE:AI btw--glad to have you here!) $\endgroup$ – DukeZhou Apr 14 at 22:22
  • $\begingroup$ Thanks ! I will do my best to clear the article up! $\endgroup$ – kostas Apr 15 at 0:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.