-1

I'm trying out logistic regression. While running the code, i get math domain error in python. Found out that i'm inputting (mx+b > 38) values large than 38 into the sigmoid function and it outputs 1, and the log function (-log(1-1)) spits out "math domain error".

Here are my steps:

  1. Find mx+b
  2. input mx+b as x in the sigmoid function
  3. Input the value from sigmoid, y-value, x-value to the cost function
  4. Find gradient from the above values.
  5. Optimize the weights using gradient value.

Please help.

Error pic

Deepak S.M
  • 51
  • 1
  • 9

1 Answers1

1

You should normalize your data before putting it into logistic function. Normalization means putting values in [0, 1] range, therefore you should not be getting 1's as outputs from sigmoid anymore. You can use this function for normalization: sklearn.preprocessing.normalize

Ach113
  • 1,775
  • 3
  • 18
  • 40