[英]Function/meaning of ~ . for train function in caret R package
train(Class ~ ., data = training,
method = "gbm",
trControl = fitControl,
## This last option is actually one
## for gbm() that passes through
verbose = FALSE)
I know that Class is predictor but what i do not understand is meaning/need of ~ .我知道 Class 是预测器,但我不明白的是~ 的含义/需要。
Any help or pointers towards help will be highly appreciated.任何帮助或指向帮助的指示将不胜感激。
PS.附注。 I am new to R
我是 R 新手
This means anything else except medv
(in this example) like the normal usage in a formula.这意味着除了
medv
(在本例中)之外的任何其他medv
,例如公式中的正常用法。 Basically you're predicting against all predictors in the dataset.基本上,您是针对数据集中的所有预测变量进行预测。 Take for instance this:
以这个为例:
library(caret)
library(mlbench)
data(BostonHousing)
lmFit <- train(medv ~ . + rm:lstat,
data = BostonHousing,
method = "lm")
To see the terms call lmFit$terms
.要查看条款,请调用
lmFit$terms
。 Of significance is this:重要的是:
medv ~ crim + zn + indus + chas + nox + rm + age + dis + rad +
tax + ptratio + b + lstat + rm:lstat
You can exclude like so:您可以像这样排除:
lmFit <- train(medv ~.-zn -so on -so on + rm:lstat,
data = BostonHousing,
method = "lm")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.