argmin icon indicating copy to clipboard operation
argmin copied to clipboard

Request to add Polars (dataframe) backend

Open humphreylee opened this issue 2 years ago • 3 comments

Would it be possible to add Polars (dataframe) as backend? Thanks.

humphreylee avatar May 09 '23 07:05 humphreylee

Can you explain a bit more about what you mean by "backend"? Do you want to use the dataframes as your Param, Gradient, or Output types in the problem?

If so, you can always implement the trait bounds from the solver on those types, and argmin should happily optimize with them. I recently just learned about this capability (see discussion).

itrumper avatar May 09 '23 13:05 itrumper

Would it be possible to add Polars (dataframe) as backend?

I haven't used Polars yet, therefore I can't really comment on this. This requires someone with Polars expertise.

If so, you can always implement the trait bounds from the solver on those types, and argmin should happily optimize with them.

That's true; however in that case you would be implementing a foreign trait on a foreign type which is prohibited by the orphan rule. To circumvent this limitation the newtype pattern is necessary. Note that this isn't really prohibiting, just a bit of an annoyance. Therefore ideally third-party backends should be supported in argmin-math, because then the traits aren't foreign.

stefan-k avatar May 10 '23 09:05 stefan-k

Can you explain a bit more about what you mean by "backend"? Do you want to use the dataframes as your Param, Gradient, or Output types in the problem?

If so, you can always implement the trait bounds from the solver on those types, and argmin should happily optimize with them. I recently just learned about this capability (see discussion).

Probably "backend" is not the correct term. What I meant is can Polars support be added similar to ndarray or nalgebra? My data (CSV) is a mix of strings and numbers, which is happily handled in dataframe (in R or Julia). The data is not pure numbers. Instead of doing multiple conversion (CSV -> polars -> ndarray / nalgebra), would love to see argmin{} handle directly Polars data format. Just a suggestion.

humphreylee avatar May 11 '23 05:05 humphreylee