generalized_additive_models.Softplus#

class generalized_additive_models.Softplus(a=1)#

Softplus link: \(g(\mu) = \log(\exp(a \mu) - 1)/a\)

__init__(a=1)#

Initialize Softplus link.

Parameters:

a (float, optional) – Positive parameter indicating how closely the inverse log function resembles \(\max(0, \mu)\). Larger values of a makes the link function more closely mimic \(\max(0, \mu)\). The default is 1.

Methods

__init__([a])

Initialize Softplus link.

derivative(mu)

Elementwise first derivative of the link function.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

inverse_link(linear_prediction)

Map from the linear space to the expected value \(\mu\).

link(mu)

Map from the expected value \(\mu\) to the unbounded linear space.

second_derivative(mu)

Elementwise second derivative of the link function.

set_params(**params)

Set the parameters of this estimator.

Attributes

domain

Domain of the link function

name

Name of the link function

derivative(mu)#

Elementwise first derivative of the link function.

domain = (0, inf)#

Domain of the link function

Map from the linear space to the expected value \(\mu\).

The softplus function is log(1 + exp(x)).

Examples

>>> linear_prediction = np.array([-10, 3, 4, 10])
>>> Softplus(a=1).inverse_link(linear_prediction)
array([4.53988992e-05, 3.04858735e+00, 4.01814993e+00, 1.00000454e+01])
>>> np.log(1 + np.exp(linear_prediction))
array([4.53988992e-05, 3.04858735e+00, 4.01814993e+00, 1.00000454e+01])

Map from the expected value \(\mu\) to the unbounded linear space.

The softplus function is log(1 + exp(x)), so the link function is the inverse, which is log(exp(x) - 1)

Examples

>>> mu = np.array([0.01, 0.1, 1., 5., 10.])
>>> Softplus(a=1).link(mu)
array([-4.60016602, -2.25216846,  0.54132485,  4.99323925,  9.9999546 ])
>>> np.log(np.exp(mu) - 1)
array([-4.60016602, -2.25216846,  0.54132485,  4.99323925,  9.9999546 ])
name = 'softplus'#

Name of the link function

second_derivative(mu)#

Elementwise second derivative of the link function.