I am new to R so I tried predicting using linear reg model and I am getting the error as shown in the image below, can you help me out?
Libraries included:
library(tidyverse)
library(ggplot2)
library(caret)
library(dplyr)
library(tidypredict)
png
Try running the library(caret) again, if the package is loaded, createDataPartition is there. If you still face the issue, check for Caret updates.
Related
When I try to forecast a time series with sma using the forecasting function I get this error:
fc <- forecast(sma(ts),h=3)
Error: The provided model is not Simple Moving Average!
Anyone knows how to fix it?
The forecast is from the fpp2 package and the moving average function is from the smooth package.
This is an example:
library(smooth)
library(fpp2)
library(readxl)
setwd("C:\\Users\\lferreira\\Desktop\\FORECASTING")
data<- read_xlsx("BASE_TESTE.xlsx")
ts <- ts(data$`1740`,start=c(2014,1),frequency=4)
> fc <- forecast(sma(ts),h=3)
Error: The provided model is not Simple Moving Average!
Your example is not reproducible because you have not provided the data.
The following example is reproducible, and does not give an error.
library(smooth)
forecast(sma(USAccDeaths))
Note that the forecast function being used here is not part of the fpp2 package. It is from the smooth package.
To check what's going on with your example:
First check that your data is correctly read in.
Then check that the sma function is returning something sensible. The error message suggests that the function is not returning the model it should.
I'm trying out Naive Bayes classification using stock dataset in R. Now for displaying the final results I've seen a function mmetric taking testing data and prediction model as arguments. But while I'm trying the same I'm facing the error could not find function "mmetric". I have installed the rminer and list packages which are quotes as reference packages for these. But still I could not resolve it.
Any Suggestions to resolve the error?
I got same error but i updated my Rcpp package that will be needed by rminer to load on the system, hope this helps.
I am going through the package documentation for randomForest to see what different functions do. I got to the margin() function and the example in the documentation did not work for me.
The code I was trying was
library(randomForest)
set.seed(1)
data(iris)
iris.rf <- randomForest(Species ~ ., iris, keep.forest=FALSE)
plot(margin(iris.rf))
I get the error
Error in unit(c(t, r, b, l), unit) : (list) object cannot be
coerced to type 'double'
I have no idea what is going wrong.
I am on using Windows 10, R version 3.3.2 (2016-10-31), randomForest v. 4.6-12
I restarted my session and everything worked again.
I must have had some sort of setting earlier in the documentation that screwed with how it interpreted the random forest.
Just jumped into this issue myself. As stated in a comment, the solution lies in specifying the package under which the margin function is desired to be used from; in this case randomForest
Thus the code line to change is
plot(randomForest::margin(iris.rf))
Pls can someone help me with how to get auto.arima working in my r. what package should i download? I tried to download auto.arima package but it was not available.
try this
install.packages("forecast")
library(forecast)
then try using the auto.arima function
I've been using randomForest.getTree to give me a text representation of each tree in my forest but have recently switched to the caret package to train the forests (method='rf'). How can I either get an object that randomForest.getTree understands (since caret is allegedly using the same underlying code) or print out the trees in some other analogous way?
just figured it out:
library(caret)
.... #load data
model <- train(x,y,method='rf')
getTree(model$finalModel)