I've been learning R in R Studio and have been working on simple prediction modeling.
I receive the following error:
Invalid argument: 'sim' & 'obs' doesn't have the same length !
when I run this line of code:
rmse(testingbabydata$weight, predictedWeight)
The dataset linked here contains 1000 rows and the global environment pane shows that my testing data and my training data have "500 obs. of 2 variables" each.
The library hydroGOF
should already be loaded properly too.
This is my code snippet wherein I attempt to predict a baby's weight based on the length of the pregnancy in weeks:
ncbabydata=read.csv("nc.csv",header=TRUE,stringsAsFactors = FALSE`)
trainingbabydata=ncbabydata[seq(1,nrow(ncbabydata),2),c("weeks","weight")]
testingbabydata=ncbabydata[seq(2,nrow(ncbabydata),2),c("weeks","weight")]
model = train(weight ~.,trainingbabydata,method="rf")
predictedWeight=predict(model,testingbabydata)
rmse(testingbabydata$weight, predictedWeight)
Thank you for your time! (I did attempt to google this error message first but found no suitable source that I could understand relatively easily.)