@@ -90,9 +90,18 @@ get_model_env <- function() {
90
90
# ' @param value A list that conforms to the `fit_obj` or `pred_obj` description
91
91
# ' above, depending on context.
92
92
# ' @keywords internal
93
+ # ' @examples
94
+ # ' # Show the infomration about a model:
95
+ # ' show_model_info("rand_forest")
96
+ # '
97
+ # ' # Access the model data:
98
+ # '
99
+ # ' current_code <- get_model_env()
100
+ # ' ls(envir = current_code)
101
+ # '
93
102
# ' @export
94
103
check_mod_val <- function (model , new = FALSE , existence = FALSE ) {
95
- if (is_missing(model ) || length(model ) != 1 )
104
+ if (rlang :: is_missing(model ) || length(model ) != 1 )
96
105
stop(" Please supply a character string for a model name (e.g. `'linear_reg'`)" ,
97
106
call. = FALSE )
98
107
@@ -120,7 +129,7 @@ check_mod_val <- function(model, new = FALSE, existence = FALSE) {
120
129
# ' @keywords internal
121
130
# ' @export
122
131
check_mode_val <- function (mode ) {
123
- if (is_missing(mode ) || length(mode ) != 1 )
132
+ if (rlang :: is_missing(mode ) || length(mode ) != 1 )
124
133
stop(" Please supply a character string for a mode (e.g. `'regression'`)" ,
125
134
call. = FALSE )
126
135
invisible (NULL )
@@ -130,7 +139,7 @@ check_mode_val <- function(mode) {
130
139
# ' @keywords internal
131
140
# ' @export
132
141
check_engine_val <- function (eng ) {
133
- if (is_missing(eng ) || length(eng ) != 1 )
142
+ if (rlang :: is_missing(eng ) || length(eng ) != 1 )
134
143
stop(" Please supply a character string for an engine (e.g. `'lm'`)" ,
135
144
call. = FALSE )
136
145
invisible (NULL )
@@ -140,7 +149,7 @@ check_engine_val <- function(eng) {
140
149
# ' @keywords internal
141
150
# ' @export
142
151
check_arg_val <- function (arg ) {
143
- if (is_missing(arg ) || length(arg ) != 1 )
152
+ if (rlang :: is_missing(arg ) || length(arg ) != 1 )
144
153
stop(" Please supply a character string for the argument" ,
145
154
call. = FALSE )
146
155
invisible (NULL )
@@ -166,7 +175,7 @@ check_func_val <- function(func) {
166
175
" element 'pkg'. These should both be single character strings."
167
176
)
168
177
169
- if (is_missing(func ) || ! is.vector(func ) || length(func ) > 2 )
178
+ if (rlang :: is_missing(func ) || ! is.vector(func ) || length(func ) > 2 )
170
179
stop(msg , call. = FALSE )
171
180
172
181
nms <- sort(names(func ))
@@ -266,7 +275,7 @@ check_pred_info <- function(pred_obj, type) {
266
275
# ' @keywords internal
267
276
# ' @export
268
277
check_pkg_val <- function (pkg ) {
269
- if (is_missing(pkg ) || length(pkg ) != 1 || ! is.character(pkg ))
278
+ if (rlang :: is_missing(pkg ) || length(pkg ) != 1 || ! is.character(pkg ))
270
279
stop(" Please supply a single character vale for the package name" ,
271
280
call. = FALSE )
272
281
invisible (NULL )
@@ -609,7 +618,7 @@ show_model_info <- function(model) {
609
618
cat(
610
619
" modes:" ,
611
620
paste0(current [[paste0(model , " _modes" )]], collapse = " , " ),
612
- " \n "
621
+ " \n\n "
613
622
)
614
623
615
624
engines <- current [[paste0(model )]]
@@ -629,6 +638,7 @@ show_model_info <- function(model) {
629
638
dplyr :: ungroup() %> %
630
639
dplyr :: pull(lab ) %> %
631
640
cat(sep = " " )
641
+ cat(" \n " )
632
642
} else {
633
643
cat(" no registered engines yet." )
634
644
}
@@ -652,17 +662,40 @@ show_model_info <- function(model) {
652
662
dplyr :: ungroup() %> %
653
663
dplyr :: pull(lab ) %> %
654
664
cat(sep = " " )
665
+ cat(" \n " )
655
666
} else {
656
667
cat(" no registered arguments yet." )
657
668
}
658
669
659
- fits <- current [[paste0(model , " _fits " )]]
670
+ fits <- current [[paste0(model , " _fit " )]]
660
671
if (nrow(fits ) > 0 ) {
661
-
672
+ cat(" fit modules:\n " )
673
+ fits %> %
674
+ dplyr :: select(- value ) %> %
675
+ mutate(engine = paste0(" " , engine )) %> %
676
+ as.data.frame() %> %
677
+ print(row.names = FALSE )
678
+ cat(" \n " )
662
679
} else {
663
680
cat(" no registered fit modules yet." )
664
681
}
665
682
683
+ preds <- current [[paste0(model , " _predict" )]]
684
+ if (nrow(preds ) > 0 ) {
685
+ cat(" prediction modules:\n " )
686
+ preds %> %
687
+ dplyr :: group_by(mode , engine ) %> %
688
+ dplyr :: summarize(methods = paste0(sort(type ), collapse = " , " )) %> %
689
+ dplyr :: ungroup() %> %
690
+ mutate(mode = paste0(" " , mode )) %> %
691
+ as.data.frame() %> %
692
+ print(row.names = FALSE )
693
+ cat(" \n " )
694
+ } else {
695
+ cat(" no registered prediction modules yet." )
696
+ }
697
+
698
+
666
699
invisible (NULL )
667
700
}
668
701
0 commit comments