R/tidiers_ml_isotonic_regression.R

Defines functions glance.ml_model_isotonic_regression augment.ml_model_isotonic_regression tidy.ml_model_isotonic_regression

Documented in augment.ml_model_isotonic_regression glance.ml_model_isotonic_regression tidy.ml_model_isotonic_regression

#' Tidying methods for Spark ML Isotonic Regression
#'
#' These methods summarize the results of Spark ML models into tidy forms.
#'
#' @param x a Spark ML model.
#' @param ... extra arguments (not used.)
#' @name ml_isotonic_regression_tidiers
NULL

#' @rdname ml_isotonic_regression_tidiers
#' @export
tidy.ml_model_isotonic_regression <- function(x,
                                              ...) {
  dplyr::tibble(
    boundaries = x$model$boundaries(),
    predictions = x$model$predictions()
  )
}

#' @rdname ml_isotonic_regression_tidiers
#' @param newdata a tbl_spark of new data to use for prediction.
#'
#' @export
augment.ml_model_isotonic_regression <- function(x, newdata = NULL,
                                                 ...) {
  broom_augment_supervised(x, newdata = newdata)
}

#' @rdname ml_isotonic_regression_tidiers
#' @export
glance.ml_model_isotonic_regression <- function(x, ...) {
  isotonic <- x$model$param_map$isotonic
  num_boundaries <- length(x$model$boundaries())

  dplyr::tibble(
    isotonic = isotonic,
    num_boundaries = num_boundaries
  )
}
rstudio/sparklyr documentation built on March 29, 2024, 3:30 p.m.