r-caret

stepwise regression using caret in R [closed]

混江龙づ霸主 提交于 2020-01-03 06:43:01
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . I have used leaps package in R to perform forward and backward feature elimination. However, I want automate the cross validation and prediction operations. Therefore, how can I use forward/backward selection in caret? in leaps package you could do it this way forward <-

caret: combine createResample and groupKFold

人盡茶涼 提交于 2020-01-02 10:15:36
问题 I want to do a custom sampling with caret . My specifications are the following: I have 1 observation per day, and my grouping factor is the month (12 values); so in the first step I create 12 resamples with 11 months in the training (11*30 points) and 1 in the testing (30 points). This way I get 12 resamples in total. But that's not enough to me and I would like to make it a little more complex, by adding some bootstrapping of the training points of each partition. So, instead of having 11

train() in caret package returns an error about names & gsub

故事扮演 提交于 2020-01-02 09:28:25
问题 I am using caret package to predict the improvementNoticed variable library(caret) head(trainData) improvementNoticed V1 V2 681 0 0.06451613 0.006060769 1484 0 0.77924586 0.331009145 1356 0 0.22222222 0.017538684 541 0 0.21505376 0.011102470 2214 1 0.59195217 0.064764408 1111 0 0.97979798 0.036445064 V3 V4 V5 681 0.008182531 0.05263158 0 1484 0.316603794 0.88825188 0 1356 0.016182822 0.20000000 0 541 0.012665610 0.10000000 0 2214 0.051008693 0.55000000 0 1111 0.034643632 0.93333333 0 and I

train() in caret package returns an error about names & gsub

ぃ、小莉子 提交于 2020-01-02 09:28:04
问题 I am using caret package to predict the improvementNoticed variable library(caret) head(trainData) improvementNoticed V1 V2 681 0 0.06451613 0.006060769 1484 0 0.77924586 0.331009145 1356 0 0.22222222 0.017538684 541 0 0.21505376 0.011102470 2214 1 0.59195217 0.064764408 1111 0 0.97979798 0.036445064 V3 V4 V5 681 0.008182531 0.05263158 0 1484 0.316603794 0.88825188 0 1356 0.016182822 0.20000000 0 541 0.012665610 0.10000000 0 2214 0.051008693 0.55000000 0 1111 0.034643632 0.93333333 0 and I

Tuning two parameters for random forest in Caret package

自作多情 提交于 2020-01-02 07:10:46
问题 When i only used mtry parameter as the tuingrid , it worked but when i added ntree parameter the error becomes Error in train.default(x, y, weights = w, ...): The tuning parameter grid should have columns mtry . The code is as below: require(RCurl) require(prettyR) library(caret) url <- "https://raw.githubusercontent.com/gastonstat/CreditScoring/master/CleanCreditScoring.csv" cs_data <- getURL(url) cs_data <- read.csv(textConnection(cs_data)) classes <- cs_data[, "Status"] predictors <- cs

Something is wrong; all the ROC metric values are missing:

谁都会走 提交于 2020-01-02 05:58:55
问题 I'm training a model in R with the caret package: ctrl <- trainControl(method = "repeatedcv", repeats = 3, summaryFunction = twoClassSummary) logitBoostFit <- train(LoanStatus~., credit, method = "LogitBoost", family=binomial, preProcess=c("center", "scale", "pca"), trControl = ctrl) I'm getting the following warnings: Warning message: In train.default(x, y, weights = w, ...): The metric "Accuracy" was not in the result set. ROC will be used instead.Warning message: In nominalTrainWorkflow(x

Logistic Regression Tuning Parameter Grid in R Caret Package?

偶尔善良 提交于 2020-01-02 04:33:06
问题 I am trying to fit a logistic regression model in R using the caret package . I have done the following: model <- train(dec_var ~., data=vars, method="glm", family="binomial", trControl = ctrl, tuneGrid=expand.grid(C=c(0.001, 0.01, 0.1, 1,10,100, 1000))) However, I am unsure what the tuning parameter should be for this model and I am having a difficult time finding it. I assumed it is C because C is the parameter used in sklearn . Currently, I am getting the following error - Error: The

Create RMSLE metric in caret in r

混江龙づ霸主 提交于 2020-01-01 19:58:09
问题 Could someone please help me with the following: I need to change my xgboost training model with caret package to an undefault metric RMSLE. By default caret and xgboost train and measure in RMSE. Here are the lines of code: create custom summary function in caret format custom_summary = function(data, lev = NULL, model = NULL){ out = rmsle(data[, "obs"], data[, "pred"]) names(out) = c("rmsle") out } create control object control = trainControl(method = "cv", number = 2, summaryFunction =

Naive Bayes in Quanteda vs caret: wildly different results

眉间皱痕 提交于 2020-01-01 12:23:31
问题 I'm trying to use the packages quanteda and caret together to classify text based on a trained sample. As a test run, I wanted to compare the build-in naive bayes classifier of quanteda with the ones in caret . However, I can't seem to get caret to work right. Here is some code for reproduction. First on the quanteda side: library(quanteda) library(quanteda.corpora) library(caret) corp <- data_corpus_movies set.seed(300) id_train <- sample(docnames(corp), size = 1500, replace = FALSE) # get

Train test split in `r`'s `caret` package

元气小坏坏 提交于 2020-01-01 10:50:09
问题 I'm getting familiar with r 's caret package, but, coming from other programming language, it thorougly confused me. What I want to do now is a fairly simple machine learning workflow, which is: Take a training set, in my case the iris dataset Split it into a training and test set (a 80-20 split) For every k from 1 to 20 , train the k nearest neighbor classifier on the training set Test it on the test set I understand how to do the first part, since iris is already loaded. Then, the second