I’m trying to reach this command:
sm(x=[3,4,1])=[0.259,0.705,0.036]
However I’m getting an error. Apparently I have a wrong syntax:
A NON-PICTURE RESULTS A minimal reproducible example is this:
import statsmodels.api as sm
sm([1,2,-4])
--------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[39], line 2
1 import statsmodels.api as sm
----> 2 sm([1,2,-4])
TypeError: 'module' object is not callable
>Solution :
Solution:
You can use the scipy package to calculate softmax as follows.
import numpy as np
from scipy.special import softmax
x=[3,4,1]
m = softmax(x)
print(m)
# [0.25949646 0.70538451 0.03511903]