view tvii/sigmoid.py @ 33:e2dd9503098f

finalize logistic regression notes
author Jeff Hammel <k0scist@gmail.com>
date Mon, 04 Sep 2017 13:29:11 -0700
parents cd43ce453358
children 38aa9098bf2d
line wrap: on
line source

"""
sigmoid function: 1/(1 + e^-z)
"""

import numpy as np
from .iterable import isiterable

def sigmoid(z):
    """https://en.wikipedia.org/wiki/Sigmoid_function"""
    if not isinstance(z, np.ndarray) and isiterable(z):
        z = np.array(z)
    return 1./(1. + np.exp(-z))