File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -24,3 +24,30 @@ is_tf_ok <- function() {
24
24
}
25
25
res
26
26
}
27
+
28
+ # ------------------------------------------------------------------------------
29
+ # For sparse tibble testing
30
+
31
+ sparse_hotel_rates <- function () {
32
+ # 99.2 sparsity
33
+ hotel_rates <- modeldata :: hotel_rates
34
+
35
+ prefix_colnames <- function (x , prefix ) {
36
+ colnames(x ) <- paste(colnames(x ), prefix , sep = " _" )
37
+ x
38
+ }
39
+
40
+ dummies_country <- hardhat :: fct_encode_one_hot(hotel_rates $ country )
41
+ dummies_company <- hardhat :: fct_encode_one_hot(hotel_rates $ company )
42
+ dummies_agent <- hardhat :: fct_encode_one_hot(hotel_rates $ agent )
43
+
44
+ res <- dplyr :: bind_cols(
45
+ hotel_rates [" avg_price_per_room" ],
46
+ prefix_colnames(dummies_country , " country" ),
47
+ prefix_colnames(dummies_company , " company" ),
48
+ prefix_colnames(dummies_agent , " agent" )
49
+ )
50
+
51
+ res <- as.matrix(res )
52
+ Matrix :: Matrix(res , sparse = TRUE )
53
+ }
You can’t perform that action at this time.
0 commit comments