itscarlayall
itscarlayall

Reputation: 166

How to get Param value from XGBoost4J?

I'm using Spark XGBoost4j with the Pyspark wrapper (https://github.com/sllynn/spark-xgboost), and I would like to know the name of the contributions column of a model. When I do:

xgboost = XGBoostClassifier(
    featuresCol="features",
    labelCol="labelCol",
    predictionCol="prediction",
    contribPredictionCol="contribs",
    seed=42,
)
xgboost.getParam("contribPredictionCol")

it outputs:

Param(parent='XGBoostClassifier_998c81888fa3', name='contribPredictionCol', doc='name of the predictContrib results')

However, I would like it to output: "contribs". How can I achieve this? Thank you.

Upvotes: 1

Views: 210

Answers (1)

itscarlayall
itscarlayall

Reputation: 166

Ok, so I have found a way:

original_name = None
for k, v in xgboost.extractParamMap().items():
    if "contribPredictionCol" in k.name:
        original_name = v

Upvotes: 2

Related Questions