-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
MNT simplify some tree code with memoryviews #12886
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
095f173
simplify apply_dense with memoryviews
adrinjalali 99b946e
change more Xs to memviews in splitter
adrinjalali 17c3bbb
remove commented out lines
adrinjalali 096276e
trying to remove y_stride
adrinjalali 7248a8c
float->dtype_t
adrinjalali a416c70
criterion has no more y_stride
adrinjalali 554b79e
remove redundant constructs and handle const y input
adrinjalali 3ae6c5a
fix criterion docstring for y's dtype
adrinjalali b136c8b
revert docstring for y
adrinjalali 5899d08
formatting: no space between type name and [:, :]
adrinjalali 95c11fb
remove redundant X
adrinjalali a5d2457
more cleanup on criterion
adrinjalali fd7b5fe
address comment
adrinjalali File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# cython: language_level=3 | ||
# Authors: Gilles Louppe <[email protected]> | ||
# Peter Prettenhofer <[email protected]> | ||
# Brian Holt <[email protected]> | ||
|
@@ -12,20 +13,19 @@ | |
import numpy as np | ||
cimport numpy as np | ||
|
||
ctypedef np.npy_float32 DTYPE_t # Type of X | ||
ctypedef np.npy_float64 DOUBLE_t # Type of y, sample_weight | ||
ctypedef np.npy_intp SIZE_t # Type for indices and counters | ||
ctypedef np.npy_int32 INT32_t # Signed 32 bit integer | ||
ctypedef np.npy_uint32 UINT32_t # Unsigned 32 bit integer | ||
from ._tree cimport DTYPE_t # Type of X | ||
from ._tree cimport DOUBLE_t # Type of y, sample_weight | ||
from ._tree cimport SIZE_t # Type for indices and counters | ||
from ._tree cimport INT32_t # Signed 32 bit integer | ||
from ._tree cimport UINT32_t # Unsigned 32 bit integer | ||
|
||
cdef class Criterion: | ||
# The criterion computes the impurity of a node and the reduction of | ||
# impurity of a split on that node. It also computes the output statistics | ||
# such as the mean in regression and class probabilities in classification. | ||
|
||
# Internal structures | ||
cdef DOUBLE_t* y # Values of y | ||
cdef SIZE_t y_stride # Stride in y (since n_outputs >= 1) | ||
cdef const DOUBLE_t[:, ::1] y # Values of y | ||
cdef DOUBLE_t* sample_weight # Sample weights | ||
|
||
cdef SIZE_t* samples # Sample indices in X, y | ||
|
@@ -53,7 +53,7 @@ cdef class Criterion: | |
# statistics correspond to samples[start:pos] and samples[pos:end]. | ||
|
||
# Methods | ||
cdef int init(self, DOUBLE_t* y, SIZE_t y_stride, DOUBLE_t* sample_weight, | ||
cdef int init(self, const DOUBLE_t[:, ::1] y, DOUBLE_t* sample_weight, | ||
double weighted_n_samples, SIZE_t* samples, SIZE_t start, | ||
SIZE_t end) nogil except -1 | ||
cdef int reset(self) nogil except -1 | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.