Python – how to use the constant e^

The function you’re using is known as the sigmoid function. You can build a function that will calculate every sigmoid of x.

In order to use e^(x) you can use the numpy function exp as shown in the example.

import numpy as np

def sigmoid(x):
    return 1/(1+np.exp(-x))

if __name__ == '__main__':
    age = 15
    result = sigmoid(-6.78+(0.04*age))
    print(result)

Leave a Comment