Skip to content
Snippets Groups Projects
  • Naftali Harris's avatar
    e3d85b7e
    Avoid numerical instability · e3d85b7e
    Naftali Harris authored
    This avoids basically doing 1 - 1, for example:
    
    ```python
    >>> from math import exp
    >>> margin = -40
    >>> 1 - 1 / (1 + exp(margin))
    0.0
    >>> exp(margin) / (1 + exp(margin))
    4.248354255291589e-18
    >>>
    ```
    
    Author: Naftali Harris <naftaliharris@gmail.com>
    
    Closes #1652 from naftaliharris/patch-2 and squashes the following commits:
    
    0d55a9f [Naftali Harris] Avoid numerical instability
    e3d85b7e
    History
    Avoid numerical instability
    Naftali Harris authored
    This avoids basically doing 1 - 1, for example:
    
    ```python
    >>> from math import exp
    >>> margin = -40
    >>> 1 - 1 / (1 + exp(margin))
    0.0
    >>> exp(margin) / (1 + exp(margin))
    4.248354255291589e-18
    >>>
    ```
    
    Author: Naftali Harris <naftaliharris@gmail.com>
    
    Closes #1652 from naftaliharris/patch-2 and squashes the following commits:
    
    0d55a9f [Naftali Harris] Avoid numerical instability
classification.py 7.26 KiB