全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
1138 3
2018-11-15
悬赏 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. ...
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
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().
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

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().
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

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

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群