softmax#
- scikitplot.utils.helpers.softmax(x)#
Compute the softmax function for each row of the input array x.
The softmax function is defined as:
softmax(x) = exp(x) / sum(exp(x))
This implementation is numerically stable by subtracting the max value in x before exponentiation to prevent overflow.
- Parameters:
x (array-like) – Input array of shape (n_samples, n_features) for which to compute the softmax. Each row represents a different sample, and each column represents a different feature or class score.
- Returns:
The softmax of each row in x, with the same shape as x.
- Return type:
array-like