special.softmax() should support pd.DataFrame as input
See original GitHub issueIs your feature request related to a problem? Please describe. when the input df is of type pandas.core.frame.DataFrame, softmax(df) doesn’t work:
gives this error
C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\ops\__init__.py in _align_method_FRAME(left, right, axis)
662 else:
663 raise ValueError(
--> 664 "Unable to coerce to DataFrame, shape "
665 f"must be {left.shape}: given {right.shape}"
666 )
Describe the solution you’d like should be able to run softmax(df)
Describe alternatives you’ve considered currently have to either run:
softmax(df.values)
or
softmax(np.array(df))
Additional context (e.g. screenshots)
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (10 by maintainers)
Top Results From Across the Web
Apply a softmax function on groupby in the same pandas ...
You can use groupby followed by transform which returns results indexed by the original dataframe. A simple way to do it would be...
Read more >scipy.special.softmax — SciPy v1.9.3 Manual
The softmax function transforms each element of a collection by computing the ... Default is None and softmax will be computed over the...
Read more >How to Make a Numpy Softmax Function - Sharp Sight
In this tutorial, I'll show you how to define a Numpy softmax function in Python. I explain the syntax and show clear, step-by-step ......
Read more >Softmax Activation Function: Everything You Need to Know
The softmax activation function transforms the raw outputs of the neural network ... You're given a dataset containing images of pandas, seals, and...
Read more >Keras and Pandas #1195 - GitHub
We can either throw an informative error, or automatically convert DataFrame to numpy object. I think it worth to add support for Pandas....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
FWIW, I agree that a pandas or xarray or … data structures shouldn’t be returned. Especially, scipy.special wouldn’t be the place to start to support it, IMO, because those are in general not typical datascience functions for end users.
pd.DataFrame(special.softmax(df), index=df.index, columns=df_columns)
should work (after fixing asarray), (but maybe you want to change column names.)I don’t think that’s special casing pandas.
The function is missing
asarray
to support general “array_like”