Skip to content

Commit

Permalink
Adds RMSE as models summary to print method
Browse files Browse the repository at this point in the history
  • Loading branch information
vwmaus committed Oct 19, 2023
1 parent c2b5f20 commit 74f341f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Depends:
ggplot2
Imports:
stats,
utils,
methods,
tidyr,
proxy
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ importFrom(methods,as)
importFrom(proxy,dist)
importFrom(stats,model.frame)
importFrom(stats,predict)
importFrom(stats,resid)
importFrom(tidyr,nest)
importFrom(tidyr,pivot_longer)
importFrom(tidyr,pivot_wider)
importFrom(tidyr,unnest)
importFrom(utils,methods)
7 changes: 5 additions & 2 deletions R/train.R
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,14 @@ print.twdtw_knn1 <- function(x, ...) {
print(x$call)

# Printing the smooth_fun, if available
cat("\nAdjusted R-squared of smooth models:\n")
cat("\nRoot Mean Squared Error (RMSE) of smooth models:\n")
if(is.null(x$smooth_models)){
print(NULL)
} else {
print(sapply(x$smooth_models, function(m1) sapply(m1, function(m2) summary(m2)$adj.r.squared)))
print(sapply(x$smooth_models, function(m1) sapply(m1, function(m2){
residuals <- try(resid(m2))
ifelse(is.numeric(residuals), sqrt(mean(residuals^2)), NA)
})))
}

# Printing the data summary
Expand Down
3 changes: 2 additions & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
#' @import sf
#' @import stars
#' @import ggplot2
#' @importFrom stats predict model.frame
#' @importFrom stats predict model.frame resid
#' @importFrom methods as
#' @importFrom utils methods
#' @importFrom tidyr pivot_longer pivot_wider nest unnest
#' @importFrom proxy dist
#'
Expand Down

0 comments on commit 74f341f

Please sign in to comment.