Skip to content

Commit

Permalink
Merge pull request #74 from jinlow/refactor/set-default-missing-value
Browse files Browse the repository at this point in the history
Set missing node to parent, if there are no missing records
  • Loading branch information
jinlow authored Sep 19, 2023
2 parents 7cb2951 + 33713e6 commit aeeb3e2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "forust-ml"
version = "0.2.25"
version = "0.2.26"
edition = "2021"
authors = ["James Inlow <[email protected]>"]
homepage = "https://github.com/jinlow/forust"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pip install forust

To use in a rust project add the following to your Cargo.toml file.
```toml
forust-ml = "0.2.25"
forust-ml = "0.2.26"
```

## Usage
Expand Down
4 changes: 2 additions & 2 deletions py-forust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "py-forust"
version = "0.2.25"
version = "0.2.26"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand All @@ -10,7 +10,7 @@ crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.19.0", features = ["extension-module"] }
forust-ml = { version = "0.2.25", path = "../" }
forust-ml = { version = "0.2.26", path = "../" }
numpy = "0.19.0"
ndarray = "0.15.1"
serde_plain = { version = "1.0" }
Expand Down
2 changes: 1 addition & 1 deletion rs-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
To run this example, add the following code to your `Cargo.toml` file.
```toml
[dependencies]
forust-ml = "0.2.25"
forust-ml = "0.2.26"
polars = "0.28"
reqwest = { version = "0.11", features = ["blocking"] }
```
Expand Down
24 changes: 16 additions & 8 deletions src/splitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,14 +396,22 @@ impl Splitter for MissingBranchSplitter {
(right_weight * right_hessian + left_weight * left_hessian)
/ (right_hessian + left_hessian)
}
MissingNodeTreatment::None => constrained_weight(
&self.get_l2(),
missing_gradient,
missing_hessian,
lower_bound,
upper_bound,
constraint,
),
MissingNodeTreatment::None => {
// If there are no missing records, just default
// to the parent weight.
if missing_hessian == 0. || missing_gradient == 0. {
parent_weight
} else {
constrained_weight(
&self.get_l2(),
missing_gradient,
missing_hessian,
lower_bound,
upper_bound,
constraint,
)
}
}
};
let missing_gain = gain_given_weight(
&self.get_l2(),
Expand Down

0 comments on commit aeeb3e2

Please sign in to comment.