Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[MAINT, Cython, Tree] Refactor 'sample_weight' double pointers to modern Cython memory views #24987

Closed
@adam2392

Description

@adam2392

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:

  1. reduced warnings in cython build (see MAINT Remove all Cython, C and C++ compilations warnings #24875)
  2. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions