question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

special.softmax() should support pd.DataFrame as input

See original GitHub issue

Is 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:open
  • Created 3 years ago
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
josef-pktcommented, May 19, 2020

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.)

1reaction
josef-pktcommented, May 19, 2020

I don’t think that’s special casing pandas.

The function is missing asarray to support general “array_like”

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found