[jvm-packages] support specified feature names when getModelDump and getFeatureScore (#3733)
* [jvm-packages] support specified feature names for jvm when get ModelDump and get FeatureScore (#3725) * typo and style fix
This commit is contained in:
@@ -187,16 +187,42 @@ class Booster private[xgboost4j](private[xgboost4j] var booster: JBooster)
|
||||
booster.getModelDump(featureMap, withStats, format)
|
||||
}
|
||||
|
||||
/**
|
||||
* Dump model as Array of string with specified feature names.
|
||||
*
|
||||
* @param featureNames Names of features.
|
||||
*/
|
||||
@throws(classOf[XGBoostError])
|
||||
def getModelDump(featureNames: Array[String]): Array[String] = {
|
||||
booster.getModelDump(featureNames, false, "text")
|
||||
}
|
||||
|
||||
def getModelDump(featureNames: Array[String], withStats: Boolean, format: String)
|
||||
: Array[String] = {
|
||||
booster.getModelDump(featureNames, withStats, format)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get importance of each feature
|
||||
*
|
||||
* @return featureMap key: feature index, value: feature importance score
|
||||
* @return featureScoreMap key: feature index, value: feature importance score
|
||||
*/
|
||||
@throws(classOf[XGBoostError])
|
||||
def getFeatureScore(featureMap: String = null): mutable.Map[String, Integer] = {
|
||||
booster.getFeatureScore(featureMap).asScala
|
||||
}
|
||||
|
||||
/**
|
||||
* Get importance of each feature with specified feature names.
|
||||
*
|
||||
* @return featureScoreMap key: feature name, value: feature importance score
|
||||
*/
|
||||
@throws(classOf[XGBoostError])
|
||||
def getFeatureScore(featureNames: Array[String]): mutable.Map[String, Integer] = {
|
||||
booster.getFeatureScore(featureNames).asScala
|
||||
}
|
||||
|
||||
def getVersion: Int = booster.getVersion
|
||||
|
||||
def toByteArray: Array[Byte] = {
|
||||
|
||||
Reference in New Issue
Block a user