I have code in R that calculates the RMSE from a Linear Regression model:
library(caTools)
library(hydroGOF)
Time <- c(406, 472, 4462, 172770, 172430, 176570)
V1 <- c(-2.312226542, -3.043540624, -2.303349568, 2.007418028, -0.446950896, -0.515512845)
Amount <- c(0, 529, 239.93, 3.99, 60.5, 9.81)
ClassABC <- c(1, 1, 1, 0, 0, 0)
df <- data.frame(Time, V1, Amount, ClassABC)
df
set.seed(2)
split <- sample.split(df, SplitRatio=0.7)
train <- subset(df, split=TRUE)
Actual <- subset(df, split=FALSE)
# Create the model
Model <- lm(ClassABC ~.,data=train)
#Prediction
Prediction <- predict(Model, Actual)
#Comparing predicted vs actual model
plot(Actual$ClassABC,type = "l",lty= 1.8,col = "red")
lines(Prediction, type = "l", col = "blue")
plot(Prediction,type = "l",lty= 1.8,col = "blue")
#Finding Accuracy
rmse <- sqrt(mean(Prediction-df2$ClassABC)^2)/diff(range(df2$ClassABC))==1
rmse
The output for the RMSE is 3.805235e-15, is it possible to normalize this using NRMSE in R? If so, how?
NRMSE()
in base R, nornrmse()
, so I assume you are using a package. Please tell us which one. If you want to transform your RMSE into a percentage, you will need to specify a meaningful baseline (a percentage of what?). And your RMSE is not $3.8$, it is $3.8e-15=3.8\times 10^{-15} =0.0000000000000038$, which still looks essentially like zero. $\endgroup$Class
, with the total number of datums (1000). I can probably do this in R code when hard coding but I want it to be dynamic if a user uploads different data, hence the use of the function. @StephanKolassa $\endgroup$