Printing with resampling weights

Aperta
#593 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
42/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
r

Direzione di ricerca

Start by locating the S3 print methods for rset and manual_rset and inspect how subclasses such as v_fold dispatch printing. Check the proposed weighted-output behavior against the existing default printing path, then verify that weighted rsets show fold_weight while unweighted objects retain their current output.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

feature

With printing in the rset objects, I think that we'll have to move this code into an rsample PR.

Most of the rsets have a superseding class (like v_fold) and the print method for that class happens first.

Using v_fold as an example, its print method removes the first two classes (v_fold and rset) so that the remaining printing is the default tibble printing. That's why there is not a rsample:::print.rset method.

I'm going to temporarily remove the print methods and make this comment an issue for rsample, and then Hannah can take a look (who is out of office next week 😿)


#' @export
print.rset <- function(x, ...) {
  fold_weights <- attr(x, ".fold_weights")

  if (!is.null(fold_weights)) {
    # Create a tibble with fold weights as a column
    x_tbl <- tibble::as_tibble(x)
    x_tbl$fold_weight <- fold_weights
    print(x_tbl, ...)
  } else {
    # Use default behavior
    NextMethod("print")
  }
}

#' @export
print.manual_rset <- function(x, ...) {
  fold_weights <- attr(x, ".fold_weights")

  if (!is.null(fold_weights)) {
    # Create a tibble with fold weights as a column
    x_tbl <- tibble::as_tibble(x)
    x_tbl$fold_weight <- fold_weights
    print(x_tbl, ...)
  } else {
    # Use default behavior for manual_rset
    NextMethod("print")
  }
}

Originally posted by @topepo in https://github.com/tidymodels/tune/issues/1007#issuecomment-3417377573

Lingua principale
R
Stelle
343
Fork
68
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di tidymodels/rsample

Tutte le issue di tidymodels/rsample

Issue simili

Altre issue su R

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.