#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    2
    Rep Power
    0

    Logistic regression Calc


    Can someone educate me on how to code this calculation in Python?
    ROUND(0.0103+1.3742*(1/(1+EXP(-1*xbeta))),4)
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,901
    Rep Power
    481
    Python is case sensitive. First convert the expression to lower case. With emacs I used C-u C-u C-u M-l . round is builtin. The 4 as its second argument tells round to use 4 decimal places. Function exp is available, but you need to load it from the math library. Finally, xbeta needs a value.

    Code:
    from math import exp
    
    xbeta = 0.2
    
    
    print(round(0.0103+1.3742*(1/(1+exp(-1*xbeta))), 4))
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    2
    Rep Power
    0
    Works like a charm thanks, it's easier when you import the math function.

IMN logo majestic logo threadwatch logo seochat tools logo