如何在R中为C5.0软件包设置成本矩阵? [英] How to set costs matrix for C5.0 Package in R?

查看:78
本文介绍了如何在R中为C5.0软件包设置成本矩阵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网上搜索了很多内容,但是没有找到R中C5.0函数的'costs'参数的有用描述。在C5.0 R手册中,它只是说成本矩阵矩阵应具有C列和行,其中C是类级别数。它不会告诉我还是是模型的预测结果。

I have googled much in the web, but don't find any useful description for the 'costs' parameter for C5.0 function in R. From the C5.0 R manual book, it just says "a matrix of costs associated with the possible errors. The matrix should have C columns and rows where C is the number of class levels". It does not tell me whether the row or the column is the predicated result by the model.

任何人都可以

推荐答案

以下是C5.0(版本0.1.0-15)的帮助页面中的报价:

Here is a quote from the help page of C5.0 (version 0.1.0-15):


成本矩阵应为CxC,其中C为类别数。
对角元素将被忽略。列应对应于真实的
类,而行则是预测的类。例如,如果C = 3,且
类别为红色,蓝色和绿色(按此顺序),则矩阵(2,3)
元素中的值为5表示预测的成本
绿色示例为蓝色,是蓝色值(通常是一个值)的五倍。

The cost matrix should by CxC, where C is the number of classes. Diagonal elements are ignored. Columns should correspond to the true classes and rows are the predicted classes. For example, if C = 3 with classes Red, Blue and Green (in that order), a value of 5 in the (2,3) element of the matrix would indicate that the cost of predicting a Green sample as Blue is five times the usual value (of one).

按照帮助页面中的示例进行操作,这将是一个成本矩阵:

Following the example in the help page, this would be a cost matrix:

cost.matrix <- matrix(c(
  NA, 2, 4,
  3, NA, 5,
  7, 1, NA

), 3, 3, byrow=TRUE)

rownames(cost.matrix) <- colnames(cost.matrix) <- c("Red", "Blue", "Green")

cost.matrix

      Red Blue Green
Red    NA    2     4
Blue    3   NA     5
Green   7    1    NA

这意味着:


  • 将红色样本预测为蓝色是通常值的3倍(一个)

  • 将红色样本预测为绿色,是通常值的7倍

  • 预测蓝色样本样本为红色是正常值的2倍

  • 预测蓝色样本为绿色是1倍常规值

  • 预测绿色样本为红色为正常值正常值的4倍

  • 将绿色样本预测为蓝色是通常值的5倍

  • Predicting a red sample as blue is 3 times the value as the usual value (one)
  • Predicting a red sample as green is 7 times the value as the usual
  • Predicting a blue sample as red is 2 times the ususal value
  • Predicting a blue sample as green is 1 times the ususal value
  • Predicting a green sample as red is 4 times the ususal value
  • Predicting a green sample as blue is 5 times the usual value

这篇关于如何在R中为C5.0软件包设置成本矩阵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆