dmlc / dmlc/xgboost

[jvm-packages]how to convert LeafPredictionCol (array type) to one hot encode

Open
#5,103 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
28.8k
Forks
8.9k
Avg merge
1d 12h
Merged PRs (30d)
54

Description

i have trained a xgbclassifier model, and get leaf indices of every tree in the format of array type, then i just want to convert leaf indices of every tree from array type to one hot encode, and after that ,i can feed the crossed feature into other models such as LR FM

`
val paramMap = List(
"objective" -> "binary:logistic",
"eval_metric" -> "auc",
"max_depth" -> 7,
"min_child_weight" -> 5.0,
"gamma" -> 0.2,
"subsample" -> 0.6,
"colsample_bytree" -> 0.6,
"colsample_bylevel" -> 0.9,
"eta" -> 0.1,
"scale_pos_weight" -> 10.0,
"seed" -> 1000L,
"num_round" -> 300,
"num_workers" -> 50,
"checkpointInterval" -> 10,
"checkpoint_path" -> checkpointPath
).toMap

val wctchVals = Map("val" -> ValDF, "test" -> TestDF)

val xgbClassifier = new XGBoostClassifier(paramMap)
.setFeaturesCol("features_vector")
.setLabelCol("label")
.setPredictionCol("prediction")
.setSilent(0)
.setEvalSets(wctchVals)
.setNumEarlyStoppingRounds(5)
.setMaximizeEvaluationMetrics(true)

val model = xgbClassifier.fit(TrainUnionDF)
model.setLeafPredictionCol("leaf_predict")
`

![image](https://user-images.githubusercontent.com/22185640/70412840-c58a2800-1a90-11ea-88e8-27beca8c7a65.png)

i have noticed the issue https://github.com/dmlc/xgboost/issues/3847 , but it does not work

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the JVM-package XGBoostClassifier API, especially setLeafPredictionCol, and compare the behavior discussed in issue #3847. Determine whether the returned leaf indices can be transformed to one-hot features for downstream LR/FM models; document the supported path or the missing capability with a reproducible example.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
machine-learning
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.