Skip to content

Instantly share code, notes, and snippets.

@lyqscmy
Created May 10, 2018 12:24
Show Gist options
  • Save lyqscmy/f12bfbdda969bf08d06ed7487e4f0228 to your computer and use it in GitHub Desktop.
Save lyqscmy/f12bfbdda969bf08d06ed7487e4f0228 to your computer and use it in GitHub Desktop.
impl XGBTree {
fn get_leaf_index(&self, feats: &FVec) -> usize {
let mut nid: usize = 0;
let mut node = &self.nodes[nid];
while !node.is_leaf() {
let split_index = node.split_index();
if feats.is_misssing(split_index) {
nid = node.cdefault();
} else {
let split_cond = node.split_cond();
if feats.fvalue(split_index) < split_cond {
nid = node.cleft();
} else {
nid = node.cright();
}
}
node = &self.nodes[nid];
}
return nid;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment