评价模型metircs optimization指南

12 篇文章 1 订阅
4 篇文章 0 订阅

本文所有内容整理自Coursera - Advanced Machine Learning- How to Win a Data Science Competition: Learn from Top Kagglers

一、定义evaluation metrics

1、基本概念

  • 一般来说,优化矩阵由组织者按照业务需求定义
  • 有些情况下,优化目标不太好量化,需要直觉判断转换为其他优化矩阵
  • 观察优化矩阵优化的趋势是否收敛良好,如果否,则采取其他优化矩阵

2、基本模型

reg回归
  • MSE 平均方差
    这里写图片描述
  • RMSE 根号下MSE(标准差):使得差异值和对象值在一个层级,而不是被平方过
    这里写图片描述
  • R-squared
    这里写图片描述
  • MAE 平均绝对差:不会过于惩罚极大极小值,对异常值比较容忍
    这里写图片描述
  • MSPE\MSAE 相对误差:计算误差的时候,考虑数据本身的体量(999-1000,和 1-2 的误差是不一样的)
    这里写图片描述
  • RMSLE 根号下log平均差
    这里写图片描述
classi分类
  • accuracy正确率
    这里写图片描述
  • logloss:倾向于容忍小的错误,而惩罚明显的差错
    这里写图片描述
  • AUC:适用于二元分类。计算分类后的,有序程度;auc是pair-wise的
    这里写图片描述
def aucfun(act,pred):
    fpr, tpr, thresholds = sklearn.metrics.roc_curve(act, pred, pos_label=1)
    return metrics.auc(fpr, tpr)
  • Cohens Kappa:给予baseline定义正确率,避免没有意义的高正确率
    这里写图片描述
# **计算loss**
def soft_kappa(preds, dtrain):
    '''
        Having predictions `preds` and targets `dtrain.get_label()` this function coumputes soft kappa loss.
        NOTE, that it assumes `mean(target) = 0`.

    '''
    target = dtrain.get_label()
    return 'kappa' ,  -2 * target.dot(preds) / (target.dot(target) + preds.dot(preds))
# **计算一阶二阶导数**
def soft_kappa_grad_hess(y, p):
    '''
        Returns first and second derivatives of the objective with respect to predictions `p`. 
        `y` is a vector of corresponding target labels.  
    '''
    norm = p.dot(p) + y.dot(y)

    grad = -2 * y / norm + 4 * p * np.dot(y, p) / (norm ** 2)
    hess = 8 * p * y / (norm ** 2) + 4 * np.dot(y, p) / (norm ** 2)  - (16 * p ** 2 * np.dot(y, p)) / (norm ** 3)
    return grad, hess
  • Quadratic weighted加权的
    这里写图片描述

3、模型训练优化

  • 可直接优化的:MSE、Logloss
  • 不可直接优化,需要先训练优化另一个模型,再讲结果在最终模型上进行检验:MSEPE、MAPE、RMSLE
  • 优化另一个模型,处理后得到最终模型:Accuracy、Kappa

二、在model中的评价模型

1、model和评价模型

这里写图片描述

2、决策树

  • 信息镝
  • gini系数:总体内包含的类别越杂乱,GINI指数就越大
  • 优劣:

1、Gini is intended for continuous attributes, and Entropy for attributes that occur in classes (e.g. colors)
2、“Gini” will tend to find the largest class, and “entropy” tends to find groups of classes that make up ~50% of the data((http://paginas.fe.up.pt/~ec/files_1011/week%2008%20-%20Decision%20Trees.pdf))
3、“Gini” to minimize misclassification
4、“Entropy” for exploratory analysis
5、Some studies show this doesn’t matter – these differ less than 2% of the time
6、Entropy may be a little slower to compute

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值