二分类模型-分布式SPARK效果评估实现代码+混淆矩阵

最近在做一个平台级的项目,为了保证分布式的可扩展性,评估最终用sparkmlib进行模型的评估,sparkmlib里面封装好了二分类、
多分类、聚类的通用的评估指标,通用指标实现起来都比较简单。

关键点:
 val metrics=new BinaryClassificationMetrics(scoreAndLable,100)
  获取到预测列和标签列,并转化为RDD[double,double]。
  • BinaryClassificationMetrics第二个参数解释:这个一个分箱参数,可能你们预测值的不同值会有几百万个,这样会导致计算量巨大,计算的结果也巨大,所以引入分箱,对预测列进行分箱降采样后进行计算。
  • 官方:param: scoreAndLabels an RDD of (score, label) pairs. param: numBins if greater than 0, then the curves (ROC curve, PR curve) computed internally will be down-sampled to this many "bins". If 0, no down-sampling will occur. This is useful because the curve contains a point for each distinct score in the input, and this could be as large as the input itself -- millions of points or more, when thousands may be entirely sufficient to summarize the curve. After down-sampling, the curves will instead be made of approximately numBins points instead. Points are made from bins of equal numbers of consecutive points. The size of each bin is floor(scoreAndLabels.count() / numBins), which means the resulting number of bins may not exactly equal numBins. The last bin in each partition may be smaller as a result, meaning
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值