Description
Summary
In #24678, it was brought up that to represent sample_weight
, we should use a memory view instead of a pointer. There is a considerable number of places that sample_weight
is used. This should result in:
- reduced warnings in cython build (see MAINT Remove all Cython, C and C++ compilations warnings #24875)
- improved maintainability by removing malloc/garbage-collection of
sample_weight
.
See https://stackoverflow.com/questions/37432076/cython-typed-memoryviews-what-they-really-are for a discussion on cython memory views vs numpy buffer vs malloced pointers.
Original Post
Making a note here for a future issue:
To explore changing this to a memview instead of a pointer, see https://cython.readthedocs.io/en/latest/src/userguide/memoryviews.html.
What you will need to do is change it here in the function header, in the function instantiation and then ctrl+f anything that "calls" sample_weight. However, imo after ctrl+fing in the tree/ submodule, this would be a larger change that I would be in favor of doing in a separate PR given PRing into scikit-learn is already pretty challenging.
Original comment: https://github.com/scikit-learn/scikit-learn/pull/24678/files#r1013113564
Originally posted by @adam2392 in #24678 (comment)