Skip to content

Commit

Permalink
added root mean square percentage error support for eXtreme Gradient …
Browse files Browse the repository at this point in the history
…Boosting
  • Loading branch information
gtesei committed Nov 10, 2015
1 parent c8caffb commit e25359f
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions R-package/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

export(RMSE.xgb)
export(RMSLE.xgb)
export(RMSPE)
export(ff.bindPath)
export(ff.blend)
export(ff.corrFilter)
Expand Down
19 changes: 19 additions & 0 deletions R-package/R/fastRegression.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,25 @@ RMSE.xgb = function (preds, dtrain) {
return(list(metric = "RMSE", value = rmse))
}

#' Root mean square percentage error
#'
#' @param dtrain the xgboost train set object.
#' @param preds the predicted values (numeric vector).
#'
#' @export
#' @return a list of metric label / values
RMSPE <- function(preds, dtrain) {
labels <- getinfo(dtrain, "label")
ignIdx = which(labels==0)
if (length(ignIdx)>0) {
labels = labels[-ignIdx]
preds = preds[-ignIdx]
}
stopifnot(sum(labels==0)==0)
err <- sqrt( mean( ((rep(1,length(preds))-preds/labels)^2) ) )
return(list(metric = "RMSPE", value = err))
}

xgb_cross_val = function( data ,
y ,
foldList,
Expand Down
20 changes: 20 additions & 0 deletions R-package/man/RMSPE.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/fastRegression.R
\name{RMSPE}
\alias{RMSPE}
\title{Root mean square percentage error}
\usage{
RMSPE(preds, dtrain)
}
\arguments{
\item{preds}{the predicted values (numeric vector).}

\item{dtrain}{the xgboost train set object.}
}
\value{
a list of metric label / values
}
\description{
Root mean square percentage error
}

Binary file modified fastfurious-manual.pdf
Binary file not shown.

0 comments on commit e25359f

Please sign in to comment.