我在Spark Mlib中使用逻辑回归进行分类,那么setLabelCol(
)和setPredictionCol()
方法有什么区别?
回答:
它们是用于设置标签和预测的非默认列名的两种方法
setLabelCol
(默认值=”label”)用于在训练时设置标签的列名。例如,在训练二元分类器时,你需要一个包含1.0或0.0的’label’列。算法将使用该列来训练模型。setPredicionCol
(默认值=”prediction”)用于在评分时设置模型输出的列名。例如,你上面训练的二元分类模型将在DataFrame中添加一个包含预测输出的新列。
你可以使用explainParams
来查看可用的参数、默认值和简要文档。例如:
scala> new LogisticRegression().explainParamsres6: String = ...featuresCol: features column name (default: features)...labelCol: label column name (default: label)...predictionCol: prediction column name (default: prediction)probabilityCol: Column name for predicted class conditional probabilities. ...