楼主: EmmaSwan13
1215 3

[问答] 随即森林score [推广有奖]

  • 0关注
  • 0粉丝

高中生

77%

还不是VIP/贵宾

-

威望
0
论坛币
2 个
通用积分
1.0000
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
229 点
帖子
10
精华
0
在线时间
45 小时
注册时间
2018-7-27
最后登录
2023-4-22

楼主
EmmaSwan13 发表于 2018-11-15 15:59:09 |AI写论文
8论坛币
求问一下,随即森林分类的原理是:比如有100棵树,其中60棵树认为这个分类是1,40棵认为是2,最后输出的是分类为1。我的问题是,random forest里面有没有指令,可以得到每次投票的结果,比如前面的例子,可以输出score=0.6?

最佳答案

jameschin007 查看完整内容

predict 函数的相关参数及取值 type 要选 votes ,返回的是投票数。 百分比你要自己算。 下面是详细解释。 type one of response, prob. or votes, indicating the type of output: predicted values, matrix of class probabilities, or matrix of vote counts. class is allowed, but automatically converted to "response", for backward compatibility. norm.votes Should the vote counts be normalized (i.e. ...
关键词:score core SCOR cor SCO

沙发
jameschin007 发表于 2018-11-15 15:59:10

predict 函数的相关参数及取值

type 要选 votes ,返回的是投票数。 百分比你要自己算。

下面是详细解释。
type
one of response, prob. or votes, indicating the type of output: predicted values, matrix of class probabilities, or matrix of vote counts. class is allowed, but automatically converted to "response", for backward compatibility.

norm.votes
Should the vote counts be normalized (i.e., expressed as fractions)? Ignored if object$type is regression.

Value
If object$type is regression, a vector of predicted values is returned. If predict.all=TRUE, then the returned object is a list of two components: aggregate, which is the vector of predicted values by the forest, and individual, which is a matrix where each column contains prediction by a tree in the forest.

If object$type is classification, the object returned depends on the argument type:

response
predicted classes (the classes with majority vote).

prob
matrix of class probabilities (one column for each class and one row for each input).

vote
matrix of vote counts (one column for each class and one row for each new input); either in raw counts or in fractions (if norm.votes=TRUE).

If predict.all=TRUE, then the individual component of the returned object is a character matrix where each column contains the predicted class by a tree in the forest.

If proximity=TRUE, the returned object is a list with two components: pred is the prediction (as described above) and proximity is the proximitry matrix. An error is issued if object$type is regression.

If nodes=TRUE, the returned object has a ``nodes'' attribute, which is an n by ntree matrix, each column containing the node number that the cases fall in for that tree.

NOTE: If the object inherits from randomForest.formula, then any data with NA are silently omitted from the prediction. The returned value will contain NA correspondingly in the aggregated and individual tree predictions (if requested), but not in the proximity or node matrices.

NOTE2: Any ties are broken at random, so if this is undesirable, avoid it by using odd number ntree in randomForest().

藤椅
jameschin007 发表于 2018-11-15 16:18:32
predict 函数的相关参数及取值


type
one of response, prob. or votes, indicating the type of output: predicted values, matrix of class probabilities, or matrix of vote counts. class is allowed, but automatically converted to "response", for backward compatibility.

norm.votes
Should the vote counts be normalized (i.e., expressed as fractions)? Ignored if object$type is regression.

Value
If object$type is regression, a vector of predicted values is returned. If predict.all=TRUE, then the returned object is a list of two components: aggregate, which is the vector of predicted values by the forest, and individual, which is a matrix where each column contains prediction by a tree in the forest.

If object$type is classification, the object returned depends on the argument type:

response
predicted classes (the classes with majority vote).

prob
matrix of class probabilities (one column for each class and one row for each input).

vote
matrix of vote counts (one column for each class and one row for each new input); either in raw counts or in fractions (if norm.votes=TRUE).

If predict.all=TRUE, then the individual component of the returned object is a character matrix where each column contains the predicted class by a tree in the forest.

If proximity=TRUE, the returned object is a list with two components: pred is the prediction (as described above) and proximity is the proximitry matrix. An error is issued if object$type is regression.

If nodes=TRUE, the returned object has a ``nodes'' attribute, which is an n by ntree matrix, each column containing the node number that the cases fall in for that tree.

NOTE: If the object inherits from randomForest.formula, then any data with NA are silently omitted from the prediction. The returned value will contain NA correspondingly in the aggregated and individual tree predictions (if requested), but not in the proximity or node matrices.

NOTE2: Any ties are broken at random, so if this is undesirable, avoid it by using odd number ntree in randomForest().

板凳
EmmaSwan13 发表于 2018-11-15 22:34:41
jameschin007 发表于 2018-11-15 16:18
predict 函数的相关参数及取值
能给个代码的例子吗?类似输出结果那种。谢谢~

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-30 05:56