-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Stats compute perf #449
base: master
Are you sure you want to change the base?
Conversation
Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Kh4L, this PR looks great so far! 🔥 Would you still be interested in finishing this PR?
val = np.hstack(ser.values) if ser.values.ndim > 1 else ser.values | ||
flattened = np.hstack(val) if val.ndim > 1 else val |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the chagne doesn't take account of the sequence_numerical
case:
self = <StatType.MEAN: 'MEAN'>
ser = 0 [nan]
1 [0.3309801272693331, nan, 0.3018088119575514]
2 ...42, nan, 0.9997390177887806, ...
19 [nan, 0.36[1182](https://github.com/pyg-team/pytorch-frame/pull/449/checks#step:6:1183)4486676457]
Name: seq_num_1, dtype: object
sep = None
def compute(
self,
ser: Series,
sep: str | None = None,
) -> Any:
if self == StatType.MEAN:
val = np.hstack(ser.values) if ser.values.ndim > 1 else ser.values
flattened = np.hstack(val) if val.ndim > 1 else val
> finite_mask = np.isfinite(flattened)
E TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
torch_frame/data/stats.py:90: TypeError
https://github.com/pyg-team/pytorch-frame/actions/runs/12376953024/job/34545299882
This PR improves performance of
StatType.compute
by callingnp.hstack
only when needed.Before change:
After change: