R/predict_iris.R

#' Iris classification on trained xgboost model
#'
#' @export
predict_iris <- function(Sepal.Length = 0, Sepal.Width = 0, Petal.Length = 0, Petal.Width = 0) {
  data_pred <- c(Sepal.Length, Sepal.Width, Petal.Length, Petal.Width)
  data_pred <- matrix(data_pred, nrow = 1)
  prob <- predict(object = model_iris, newdata = data_pred)
  label = iris_levels[which.max(prob)]
  return(list(label = label, prob = prob))
}
jeremiedb/PredictionEngine documentation built on May 10, 2019, 12:09 a.m.