[ 
https://issues.apache.org/jira/browse/SPARK-2552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14067419#comment-14067419
 ] 

Xiangrui Meng commented on SPARK-2552:
--------------------------------------

It is not necessary to check the ranges because exp never underflows on a 
negative number. So the function is just

{code}
def logistic(x):
  if x > 0:
    return 1 / (1 + math.exp(-x))
  else
    return 1 - 1 / (1 + math.exp(x))
{code}


> Stabilize the computation of logistic function in pyspark
> ---------------------------------------------------------
>
>                 Key: SPARK-2552
>                 URL: https://issues.apache.org/jira/browse/SPARK-2552
>             Project: Spark
>          Issue Type: Bug
>          Components: MLlib, PySpark
>            Reporter: Xiangrui Meng
>              Labels: Starter
>
> exp(1000) throws an error in python. For logistic function, we can use either 
> 1 / ( 1 + exp( -x ) ) or 1 - 1 / (1 + exp( x ) ) to compute its value which 
> ensuring exp always takes a negative value.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to