-
Notifications
You must be signed in to change notification settings - Fork 105
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
Add Pearsons correlation to _column_associations #1203
base: main
Are you sure you want to change the base?
Conversation
This is the output, which I excluded for now, due to errors:
Not sure why Pearson is showing up as
|
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 @reshamas, thank you for starting this!
In skrub, we use methods defined in skrub._dataframe._common.py
to dispatch operations on polars or pandas dataframes. We do this to avoid copying dataframes from one backend to the other, and later to enable features like lazy evaluation. Therefore, the input of the function skrub._column_associations.column_associations()
could be either a pandas or a polars DataFrame.
So, here, we would like to use something like sbd.corr()
("sbd" stands for "skrub dataframe"), instead of pandas corr. Since this method doesn't exist yet, you'll have to add it to skrub._dataframe._common.py
😁
Alternatively, you could turn your dataframe into a numpy array with skb.to_numpy()
and then use np.corrcoef
. I slightly prefer the former suggestion because it adds corr()
in skrub, which I think would be also useful later.
If you go with the first option, I suggest converting the output to a numpy 2d array, so that you can directly use the _stack_symmetric_associations()
function to melt the symmetric matrix into a long format. You need to select only numeric columns when passing your dataframe to _stack_symmetric_associations()
.
Finally, you can apply the merge operation with skrub._join_utils.left_join
.
We know that developing skrub is fairly involved at the moment, and we plan on making a simple documentation for all our internals. In the meantime, I'm here to help you to move this PR forward!
Towards #1176
Add Pearsons correlation to column associations.