如何使用 Spark 决策树调整分类阈值
How to Adjust Classification Threshold with a Spark Decision Tree
我正在使用 Spark 2.0 和新的 spark.ml。包裹。
有没有办法调整分类阈值,以便减少误报的数量。
如果重要的话,我也在使用 CrossValidator。
我看到 RandomForestClassifier 和 DecisionTreeClassifier 都输出一个概率列(我可以手动使用,但 GBTClassifier 不能。
听起来您可能正在寻找 thresholds
参数:
final val thresholds: DoubleArrayParam
Param for Thresholds in multi-class classification to adjust the probability
of predicting each class. Array must have length equal to the number of
classes, with values >= 0. The class with largest value p/t is predicted,
where p is the original probability of that class and t is the class'
threshold.
您需要通过在分类器上调用 setThresholds(value: Array[Double])
来设置它。
我正在使用 Spark 2.0 和新的 spark.ml。包裹。 有没有办法调整分类阈值,以便减少误报的数量。 如果重要的话,我也在使用 CrossValidator。
我看到 RandomForestClassifier 和 DecisionTreeClassifier 都输出一个概率列(我可以手动使用,但 GBTClassifier 不能。
听起来您可能正在寻找 thresholds
参数:
final val thresholds: DoubleArrayParam
Param for Thresholds in multi-class classification to adjust the probability of predicting each class. Array must have length equal to the number of classes, with values >= 0. The class with largest value p/t is predicted, where p is the original probability of that class and t is the class' threshold.
您需要通过在分类器上调用 setThresholds(value: Array[Double])
来设置它。