scipy.special.expit#

scipy.special.expit(x, out=None) = <ufunc 'expit'>#

Expit (auch bekannt als logistische Sigmoidfunktion) ufunc für ndarrays.

Die Expit-Funktion, auch bekannt als logistische Sigmoidfunktion, ist definiert als expit(x) = 1/(1+exp(-x)). Sie ist die Umkehrfunktion der Logit-Funktion.

Parameter:
xndarray

Das ndarray, auf das expit elementweise angewendet werden soll.

outndarray, optional

Optionales Ausgabe-Array für die Funktionswerte

Rückgabe:
skalar oder ndarray

Ein ndarray mit derselben Form wie x. Seine Einträge sind expit des entsprechenden Eintrags von x.

Siehe auch

logit

Hinweise

Als ufunc nimmt expit eine Reihe optionaler Schlüsselwortargumente entgegen. Weitere Informationen finden Sie unter ufuncs

Hinzugefügt in Version 0.10.0.

expit hat experimentelle Unterstützung für Backends, die dem Python Array API Standard entsprechen, zusätzlich zu NumPy. Bitte erwägen Sie, diese Funktionen zu testen, indem Sie die Umgebungsvariable SCIPY_ARRAY_API=1 setzen und CuPy-, PyTorch-, JAX- oder Dask-Arrays als Array-Argumente übergeben. Die folgenden Kombinationen von Backend und Gerät (oder anderer Fähigkeit) werden unterstützt.

Bibliothek

CPU

GPU

NumPy

n/a

CuPy

n/a

PyTorch

JAX

Dask

n/a

Siehe Unterstützung für den Array API Standard für weitere Informationen.

Beispiele

>>> import numpy as np
>>> from scipy.special import expit, logit
>>> expit([-np.inf, -1.5, 0, 1.5, np.inf])
array([ 0.        ,  0.18242552,  0.5       ,  0.81757448,  1.        ])

logit ist die Umkehrfunktion von expit

>>> logit(expit([-2.5, 0, 3.1, 5.0]))
array([-2.5,  0. ,  3.1,  5. ])

Plotten von expit(x) für x in [-6, 6]

>>> import matplotlib.pyplot as plt
>>> x = np.linspace(-6, 6, 121)
>>> y = expit(x)
>>> plt.plot(x, y)
>>> plt.grid()
>>> plt.xlim(-6, 6)
>>> plt.xlabel('x')
>>> plt.title('expit(x)')
>>> plt.show()
../../_images/scipy-special-expit-1.png