• 主页
  • 课程

    关于课程

    • 课程归档
    • 成为一名讲师
    • 讲师信息
    同等学历教学

    同等学历教学

    免费
    阅读更多
  • 特色
    • 展示
    • 关于我们
    • 问答
  • 事件
  • 个性化
  • 博客
  • 联系
  • 站点资源
    有任何问题吗?
    (00) 123 456 789
    weinfoadmin@weinformatics.cn
    注册登录
    恒诺新知
    • 主页
    • 课程

      关于课程

      • 课程归档
      • 成为一名讲师
      • 讲师信息
      同等学历教学

      同等学历教学

      免费
      阅读更多
    • 特色
      • 展示
      • 关于我们
      • 问答
    • 事件
    • 个性化
    • 博客
    • 联系
    • 站点资源

      R语言

      • 首页
      • 博客
      • R语言
      • 模型|公司需要模型的可解释性

      模型|公司需要模型的可解释性

      • 发布者 weinfoadmin
      • 分类 R语言
      • 日期 2019年5月2日
      测试开头

      编者按:模型的可解释是非常重要,很多业务问题的解决与策略,都需要合理的解释。金融科技领域的评分卡模型,为什么偏爱逻辑回归算法,模型的可解释性是一个很重要的原因。我创建了R语言微信群,定位:R语言学习与实践,要进群的朋友,添加我微信:luqin360。

      对于机器学习模型的可解释性有很多方法,但是它们都缺少什么呢?

      LIME的ICE和部分依赖图不能告诉我拟合关系的准确性。此外,ICE没有确切地告诉我每条线发生的概率。您的模型很容易对数据进行欠拟合和过拟合,尤其是在使用深度学习模型时。LIME(应该叫LAME)没能告诉我模型实际上是如何运行的。

      假设您正在处理一个价格弹性模型,该模型将指导定价决策。目前,您将显示模型能够拟合的关系。考虑到我们将使用一个模型来指导定价决策,一个明智的利益相关者可能会问,“我看到了您的模型所拟合的关系,但是我如何知道它与实际的关系相对应呢?”

      你会做什么?给利益相关者一些模型精度度量?告诉他们你使用了深度学习,所以他们应该相信它,因为它是最先进的技术?

      这里有一个解决部分依赖关系图不足的简单方法:对预测关系使用校准。就是这么简单。下面是来自r中的RemixAutoML包的一个示例图。x轴是感兴趣的自变量。刻度间的间距是根据自变量分布的百分位数确定的。这意味着,在x轴上,数据是均匀分布的,因此不需要如ICE图表中所示的dashes。 其次,我们可以看到自变量与目标变量的关系,部分依赖图也是如此,但我们也可以看到模型在自变量范围内的拟合程度。 这解决了利益相关者对预测准确性的怀疑。 如果您想查看预测的可变性,请使用boxplot版本。 如果要查看特定组的关系,只需将数据子集化,以便仅包含该感兴趣的组,然后重新运行该函数。

      #######################################################
      # Create data to simulate validation data with predicted values
      #######################################################

      # Correl: This is the correlation used to determine how correlated the variables are to 
      # the target variable. Switch it up (between 0 and 1) to see how the charts below change.
      Correl <- 0.85
      data <- data.table::data.table(Target = runif(1000))
      #  Mock independent variables - they are correlated variables with 
      # various transformations so you can see different kinds of relationships 
      # in the charts below

      # Helper columns for creating simulated variables 
      data[, x1 := qnorm(Target)]
      data[, x2 := runif(1000)]

      # Create one variable at a time
      data[, Independent_Variable1 := log(pnorm(Correl * x1 +
                                  sqrt(1-Correl^2) * qnorm(x2)))]
      data[, Independent_Variable2 := (pnorm(Correl * x1 +
                                          sqrt(1-Correl^2) * qnorm(x2)))]
      data[, Independent_Variable3 := exp(pnorm(Correl * x1 +
                                              sqrt(1-Correl^2) * qnorm(x2)))]
      data[, Independent_Variable4 := exp(exp(pnorm(Correl * x1 +
                                                  sqrt(1-Correl^2) * qnorm(x2))))]
      data[, Independent_Variable5 := sqrt(pnorm(Correl * x1 +
                                              sqrt(1-Correl^2) * qnorm(x2)))]
      data[, Independent_Variable6 := (pnorm(Correl * x1 +
                                          sqrt(1-Correl^2) * qnorm(x2)))^0.10]
      data[, Independent_Variable7 := (pnorm(Correl * x1 +
                                          sqrt(1-Correl^2) * qnorm(x2)))^0.25]
      data[, Independent_Variable8 := (pnorm(Correl * x1 +
                                          sqrt(1-Correl^2) * qnorm(x2)))^0.75]
      data[, Independent_Variable9 := (pnorm(Correl * x1 +
                                          sqrt(1-Correl^2) * qnorm(x2)))^2]
      data[, Independent_Variable10 := (pnorm(Correl * x1 +
                                              sqrt(1-Correl^2) * qnorm(x2)))^4]

      data[, Independent_Variable11 := ifelse(Independent_Variable2 < 0.20, "A",
                                          ifelse(Independent_Variable2 < 0.40, "B",
                                                  ifelse(Independent_Variable2 < 0.6, "C",
                                                          ifelse(Independent_Variable2 < 0.8, "D", "E"))))]

      # We’ll use this as a mock predicted value
      data[, Predict := (pnorm(Correl * x1 +
                              sqrt(1-Correl^2) * qnorm(x2)))]

      # Remove the helper columns
      data[, ':=' (x1 = NULL, x2 = NULL)]

      # In the ParDepCalPlot() function below, note the Function argument - 
      # we are using mean() to aggregate our values but you 
      # can use quantile(x, probs = y) for quantile regression

      # Partial Dependence Calibration Plot: 
      p1 <- RemixAutoML::ParDepCalPlots(data,
                                      PredictionColName = "Predict",
                                      TargetColName = "Target",
                                      IndepVar = "Independent_Variable1",
                                      GraphType = "calibration",
                                      PercentileBucket = 0.05,
                                      FactLevels = 10,
                                      Function = function(x) mean(x, na.rm = TRUE))

      # Partial Dependence Calibration BoxPlot:  note the GraphType argument
      p2 <- RemixAutoML::ParDepCalPlots(data,
                                      PredictionColName = "Predict",
                                      TargetColName = "Target",
                                      IndepVar = "Independent_Variable1",
                                      GraphType = "boxplot",
                                      PercentileBucket = 0.05,
                                      FactLevels = 10,
                                      Function = function(x) mean(x, na.rm = TRUE))

      # Partial Dependence Calibration Plot: 
      p3 <- RemixAutoML::ParDepCalPlots(data,
                                         PredictionColName = "Predict",
                                         TargetColName = "Target",
                                         IndepVar = "Independent_Variable4",
                                         GraphType = "calibration",
                                         PercentileBucket = 0.05,
                                         FactLevels = 10,
                                         Function = function(x) mean(x, na.rm = TRUE))

      # Partial Dependence Calibration BoxPlot for factor variables: 
      p4 <- RemixAutoML::ParDepCalPlots(data,
                                         PredictionColName = "Predict",
                                         TargetColName  = "Target",
                                         IndepVar = "Independent_Variable11",
                                         GraphType = "calibration",
                                         PercentileBucket = 0.05,
                                         FactLevels = 10,
                                         Function = function(x) mean(x, na.rm = TRUE))

      # Plot all the individual graphs in a single pane
      RemixAutoML::multiplot(plotlist = list(p1,p2,p3,p4), cols = 2)
      模型|公司需要模型的可解释性

      原文链接:
      https://www.remixinstitute.com/blog/companies-are-demanding-model-interpretability-heres-how-to-do-it-right/#.XMpYk44zbIU

      您若是觉得有用,请点赞和分享给朋友或者同事。
      您有任何问题或者想法,请留言或者评论。

      内容推荐


      • 视频|RStudio项目和版本控制

      • 视频|我常用的R包

      • 视频|R语言编码风格

      • 视频|RMarkdown帮准您做数据报告

      测试结尾

      请关注“恒诺新知”微信公众号,感谢“R语言“,”数据那些事儿“,”老俊俊的生信笔记“,”冷🈚️思“,“珞珈R”,“生信星球”的支持!

      • 分享:
      作者头像
      weinfoadmin

      上一篇文章

      哈佛R语言课程--7.R语言进行数据可视化
      2019年5月2日

      下一篇文章

      R的xlsx包可能会有个报错
      2019年5月2日

      你可能也喜欢

      3-1665801675
      R语言学习:重读《R数据科学(中文版)》书籍
      28 9月, 2022
      6-1652833487
      经典铁死亡,再出新思路
      16 5月, 2022
      1-1651501980
      R语言学习:阅读《R For Everyone 》(第二版)
      1 5月, 2022

      搜索

      分类

      • R语言
      • TCGA数据挖掘
      • 单细胞RNA-seq测序
      • 在线会议直播预告与回放
      • 数据分析那些事儿分类
      • 未分类
      • 生信星球
      • 老俊俊的生信笔记

      投稿培训

      免费

      alphafold2培训

      免费

      群晖配置培训

      免费

      最新博文

      Nature | 单细胞技术揭示衰老细胞与肌肉再生
      301月2023
      lncRNA和miRNA生信分析系列讲座免费视频课和课件资源包,干货满满
      301月2023
      如何快速批量修改 Git 提交记录中的用户信息
      261月2023
      logo-eduma-the-best-lms-wordpress-theme

      (00) 123 456 789

      weinfoadmin@weinformatics.cn

      恒诺新知

      • 关于我们
      • 博客
      • 联系
      • 成为一名讲师

      链接

      • 课程
      • 事件
      • 展示
      • 问答

      支持

      • 文档
      • 论坛
      • 语言包
      • 发行状态

      推荐

      • iHub汉语代码托管
      • iLAB耗材管理
      • WooCommerce
      • 丁香园论坛

      weinformatics 即 恒诺新知。ICP备案号:粤ICP备19129767号

      • 关于我们
      • 博客
      • 联系
      • 成为一名讲师

      要成为一名讲师吗?

      加入数以千计的演讲者获得100%课时费!

      现在开始

      用你的站点账户登录

      忘记密码?

      还不是会员? 现在注册

      注册新帐户

      已经拥有注册账户? 现在登录

      close
      会员购买 你还没有登录,请先登录
      • ¥99 VIP-1个月
      • ¥199 VIP-半年
      • ¥299 VIP-1年
      在线支付 激活码

      立即支付
      支付宝
      微信支付
      请使用 支付宝 或 微信 扫码支付
      登录
      注册|忘记密码?