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().