Skip to content

Commit 20104e1

Browse files
authored
Merge pull request #14 from vaaaaanquish/release_1.4.2
Update XGBoost 1.4.2
2 parents 5e84292 + cc2c6cb commit 20104e1

File tree

14 files changed

+94
-100
lines changed

14 files changed

+94
-100
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[submodule "xgboost-sys/xgboost"]
22
path = xgboost-sys/xgboost
33
url = https://github.com/davechallis/xgboost
4-
branch = v0.80-modified
4+
branch = master

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "xgboost"
3-
version = "0.1.4"
3+
version = "0.2.0"
44
authors = ["Dave Challis <[email protected]>"]
55
license = "MIT"
66
repository = "https://github.com/davechallis/rust-xgboost"
@@ -10,7 +10,7 @@ documentation = "https://docs.rs/xgboost"
1010
readme = "README.md"
1111

1212
[dependencies]
13-
xgboost-sys = "0.1.2"
13+
xgboost-sys = "0.2.0"
1414
libc = "0.2"
1515
derive_builder = "0.5"
1616
log = "0.4"

examples/basic/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ publish = false
66

77
[dependencies]
88
xgboost = { path = "../../" }
9-
sprs = "0.6"
9+
sprs = "0.11"
1010
log = "0.4"
1111
env_logger = "0.5"

examples/basic/src/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,14 @@ fn main() {
114114
}
115115

116116
// work out size of sparse matrix from max row/col values
117-
let shape = (*rows.iter().max().unwrap() + 1 as usize,
118-
*cols.iter().max().unwrap() + 1 as usize);
117+
let shape = ((*rows.iter().max().unwrap() + 1) as usize,
118+
(*cols.iter().max().unwrap() + 1) as usize);
119+
let num_col = Some((*cols.iter().max().unwrap() + 1) as usize);
119120
let triplet_mat = sprs::TriMatBase::from_triplets(shape, rows, cols, data);
120121
let csr_mat = triplet_mat.to_csr();
121122

122123
let indices: Vec<usize> = csr_mat.indices().into_iter().map(|i| *i as usize).collect();
123-
let mut dtrain = DMatrix::from_csr(csr_mat.indptr(), &indices, csr_mat.data(), None).unwrap();
124+
let mut dtrain = DMatrix::from_csr(csr_mat.indptr().raw_storage(), &indices, csr_mat.data(), num_col).unwrap();
124125
dtrain.set_labels(&labels).unwrap();
125126

126127
let training_params = parameters::TrainingParametersBuilder::default().dtrain(&dtrain).build().unwrap();

examples/multiclass_classification/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ publish = false
88
xgboost = { path = "../../" }
99
log = "0.4"
1010
env_logger = "0.5"
11-
reqwest = "0.8"
11+
reqwest = { version = "0.11", features = ["blocking"] }

examples/multiclass_classification/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fn download_dataset<P: AsRef<Path>>(dst: P) {
7373
}
7474

7575
debug!("Fetching training dataset from {}", url);
76-
let mut response = reqwest::get(url).expect("failed to download training set data");
76+
let mut response = reqwest::blocking::get(url).expect("failed to download training set data");
7777

7878
let file = File::create(dst).expect(&format!("failed to create file {}", dst.display()));
7979
let mut writer = BufWriter::new(file);

src/booster.rs

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ impl Booster {
361361
dmat.handle,
362362
option_mask,
363363
ntree_limit,
364+
0,
364365
&mut out_len,
365366
&mut out_result))?;
366367

@@ -381,10 +382,10 @@ impl Booster {
381382
dmat.handle,
382383
option_mask,
383384
ntree_limit,
385+
1,
384386
&mut out_len,
385387
&mut out_result))?;
386388
assert!(!out_result.is_null());
387-
388389
let data = unsafe { slice::from_raw_parts(out_result, out_len as usize).to_vec() };
389390
Ok(data)
390391
}
@@ -403,6 +404,7 @@ impl Booster {
403404
dmat.handle,
404405
option_mask,
405406
ntree_limit,
407+
0,
406408
&mut out_len,
407409
&mut out_result))?;
408410
assert!(!out_result.is_null());
@@ -429,6 +431,7 @@ impl Booster {
429431
dmat.handle,
430432
option_mask,
431433
ntree_limit,
434+
0,
432435
&mut out_len,
433436
&mut out_result))?;
434437
assert!(!out_result.is_null());
@@ -456,6 +459,7 @@ impl Booster {
456459
dmat.handle,
457460
option_mask,
458461
ntree_limit,
462+
0,
459463
&mut out_len,
460464
&mut out_result))?;
461465
assert!(!out_result.is_null());
@@ -623,7 +627,6 @@ impl FeatureMap {
623627
};
624628
features.0.insert(feature_num, (feature_name.to_string(), feature_type));
625629
}
626-
627630
Ok(features)
628631
}
629632
}
@@ -704,7 +707,8 @@ mod tests {
704707

705708
#[test]
706709
fn save_and_load_from_buffer() {
707-
let mut booster = load_test_booster();
710+
let dmat_train = DMatrix::load("xgboost-sys/xgboost/demo/data/agaricus.txt.train").unwrap();
711+
let mut booster = Booster::new_with_cached_dmats(&BoosterParameters::default(), &[&dmat_train]).unwrap();
708712
let attr = booster.get_attribute("foo").expect("Getting attribute failed");
709713
assert_eq!(attr, None);
710714

@@ -939,6 +943,8 @@ mod tests {
939943
fn dump_model() {
940944
let dmat_train = DMatrix::load("xgboost-sys/xgboost/demo/data/agaricus.txt.train").unwrap();
941945

946+
println!("{:?}", dmat_train.shape());
947+
942948
let tree_params = tree::TreeBoosterParametersBuilder::default()
943949
.max_depth(2)
944950
.eta(1.0)
@@ -963,75 +969,75 @@ mod tests {
963969
.expect("failed to parse feature map file");
964970

965971
assert_eq!(booster.dump_model(true, Some(&features)).unwrap(),
966-
"0:[odor=pungent] yes=2,no=1,gain=4000.53101,cover=1628.25
967-
1:[stalk-root=cup] yes=4,no=3,gain=1158.21204,cover=924.5
972+
"0:[odor=none] yes=2,no=1,gain=4000.53101,cover=1628.25
973+
1:[stalk-root=club] yes=4,no=3,gain=1158.21204,cover=924.5
968974
3:leaf=1.71217716,cover=812
969975
4:leaf=-1.70044053,cover=112.5
970-
2:[spore-print-color=orange] yes=6,no=5,gain=198.173828,cover=703.75
976+
2:[spore-print-color=green] yes=6,no=5,gain=198.173828,cover=703.75
971977
5:leaf=-1.94070864,cover=690.5
972978
6:leaf=1.85964918,cover=13.25
973979
974-
0:[stalk-root=missing] yes=2,no=1,gain=832.545044,cover=788.852051
975-
1:[odor=pungent] yes=4,no=3,gain=569.725098,cover=768.389709
980+
0:[stalk-root=rooted] yes=2,no=1,gain=832.545044,cover=788.852051
981+
1:[odor=none] yes=4,no=3,gain=569.725098,cover=768.389709
976982
3:leaf=0.78471756,cover=458.936859
977983
4:leaf=-0.968530357,cover=309.45282
978984
2:leaf=-6.23624468,cover=20.462389
979985
980-
0:[ring-type=sheathing] yes=2,no=1,gain=368.744568,cover=457.069458
981-
1:[stalk-surface-below-ring=silky] yes=4,no=3,gain=226.33696,cover=221.051468
986+
0:[ring-type=pendant] yes=2,no=1,gain=368.744568,cover=457.069458
987+
1:[stalk-surface-below-ring=scaly] yes=4,no=3,gain=226.33696,cover=221.051468
982988
3:leaf=0.658725023,cover=212.999451
983989
4:leaf=5.77228642,cover=8.05200672
984-
2:[spore-print-color=white] yes=6,no=5,gain=258.184265,cover=236.018005
990+
2:[spore-print-color=purple] yes=6,no=5,gain=258.184265,cover=236.018005
985991
5:leaf=-0.791407049,cover=233.487625
986992
6:leaf=-9.421422,cover=2.53038669
987993
988-
0:[odor=musty] yes=2,no=1,gain=140.486069,cover=364.119354
989-
1:[gill-size=narrow] yes=4,no=3,gain=139.860504,cover=274.101959
994+
0:[odor=foul] yes=2,no=1,gain=140.486069,cover=364.119354
995+
1:[gill-size=broad] yes=4,no=3,gain=139.860504,cover=274.101959
990996
3:leaf=0.614153326,cover=95.8599854
991997
4:leaf=-0.877905607,cover=178.241974
992998
2:leaf=1.07747853,cover=90.0174103
993999
994-
0:[spore-print-color=orange] yes=2,no=1,gain=112.605011,cover=189.202194
995-
1:[gill-spacing=crowded] yes=4,no=3,gain=66.4029999,cover=177.771835
1000+
0:[spore-print-color=green] yes=2,no=1,gain=112.605011,cover=189.202194
1001+
1:[gill-spacing=close] yes=4,no=3,gain=66.4029999,cover=177.771835
9961002
3:leaf=-1.26934469,cover=42.277401
9971003
4:leaf=0.152607277,cover=135.494431
9981004
2:leaf=2.92190909,cover=11.4303684
9991005
1000-
0:[odor=anise] yes=2,no=1,gain=52.5610275,cover=170.612762
1001-
1:[odor=creosote] yes=4,no=3,gain=67.3869553,cover=150.881165
1006+
0:[odor=almond] yes=2,no=1,gain=52.5610275,cover=170.612762
1007+
1:[odor=anise] yes=4,no=3,gain=67.3869553,cover=150.881165
10021008
3:leaf=0.431742132,cover=131.902222
10031009
4:leaf=-1.53846073,cover=18.9789505
1004-
2:[gill-spacing=crowded] yes=6,no=5,gain=12.4420624,cover=19.731596
1010+
2:[gill-spacing=close] yes=6,no=5,gain=12.4420624,cover=19.731596
10051011
5:leaf=-3.02413678,cover=3.65769386
10061012
6:leaf=-1.02315068,cover=16.0739021
10071013
1008-
0:[odor=pungent] yes=2,no=1,gain=66.2389145,cover=142.360611
1009-
1:[odor=creosote] yes=4,no=3,gain=31.2294312,cover=72.7557373
1014+
0:[odor=none] yes=2,no=1,gain=66.2389145,cover=142.360611
1015+
1:[odor=anise] yes=4,no=3,gain=31.2294312,cover=72.7557373
10101016
3:leaf=0.777142286,cover=64.5309982
10111017
4:leaf=-1.19710124,cover=8.22473907
1012-
2:[spore-print-color=orange] yes=6,no=5,gain=12.1987419,cover=69.6048737
1018+
2:[spore-print-color=green] yes=6,no=5,gain=12.1987419,cover=69.6048737
10131019
5:leaf=-0.912605286,cover=66.1211166
10141020
6:leaf=0.836115122,cover=3.48375821
10151021
1016-
0:[gill-size=narrow] yes=2,no=1,gain=20.6531773,cover=79.4027634
1017-
1:[spore-print-color=yellow] yes=4,no=3,gain=16.0703697,cover=34.9289207
1022+
0:[gill-size=broad] yes=2,no=1,gain=20.6531773,cover=79.4027634
1023+
1:[spore-print-color=white] yes=4,no=3,gain=16.0703697,cover=34.9289207
10181024
3:leaf=-0.0180106498,cover=25.0319824
10191025
4:leaf=1.4361918,cover=9.89693928
1020-
2:[odor=musty] yes=6,no=5,gain=22.1144333,cover=44.4738464
1026+
2:[odor=foul] yes=6,no=5,gain=22.1144333,cover=44.4738464
10211027
5:leaf=-0.908311546,cover=36.982872
10221028
6:leaf=0.890622675,cover=7.49097395
10231029
1024-
0:[odor=anise] yes=2,no=1,gain=11.7128553,cover=53.3251991
1025-
1:[ring-type=sheathing] yes=4,no=3,gain=12.546154,cover=44.299942
1030+
0:[odor=almond] yes=2,no=1,gain=11.7128553,cover=53.3251991
1031+
1:[ring-type=pendant] yes=4,no=3,gain=12.546154,cover=44.299942
10261032
3:leaf=-0.515293062,cover=15.7899179
10271033
4:leaf=0.56883812,cover=28.5100231
10281034
2:leaf=-1.01502442,cover=9.02525806
10291035
1030-
0:[population=numerous] yes=2,no=1,gain=14.8892794,cover=45.9312019
1031-
1:[odor=pungent] yes=4,no=3,gain=10.1308851,cover=43.0564575
1036+
0:[population=clustered] yes=2,no=1,gain=14.8892794,cover=45.9312019
1037+
1:[odor=none] yes=4,no=3,gain=10.1308851,cover=43.0564575
10321038
3:leaf=0.217203051,cover=22.3283749
10331039
4:leaf=-0.734555721,cover=20.7280827
1034-
2:[stalk-surface-above-ring=fibrous] yes=6,no=5,gain=19.3462334,cover=2.87474418
1040+
2:[stalk-root=missing] yes=6,no=5,gain=19.3462334,cover=2.87474418
10351041
5:leaf=3.63442755,cover=1.34154534
10361042
6:leaf=-0.609474957,cover=1.53319895
10371043
");

0 commit comments

Comments
 (0)