Fetches feature information from a given data set
get_data_specs(x)
matrix, data.frame or data.table The data to extract feature information from.
A list with the following elements:
character vector with the feature names to compute Shapley values for
a named character vector with the labels as names and the class types as elements
a named list with the labels as names and character vectors with the factor levels as elements (NULL if the feature is not a factor)
This function is used to extract the feature information to be checked against the corresponding information extracted from the model and other data sets. The function is called from internally
# Load example data
data("airquality")
airquality <- airquality[complete.cases(airquality), ]
# Split data into test- and training data
x_train <- head(airquality, -3)
x_explain <- tail(airquality, 3)
# Split data into test- and training data
x_train <- data.table::as.data.table(head(airquality))
x_train[, Temp := as.factor(Temp)]
#> Ozone Solar.R Wind Temp Month Day
#> <int> <int> <num> <fctr> <int> <int>
#> 1: 41 190 7.4 67 5 1
#> 2: 36 118 8.0 72 5 2
#> 3: 12 149 12.6 74 5 3
#> 4: 18 313 11.5 62 5 4
#> 5: 23 299 8.6 65 5 7
#> 6: 19 99 13.8 59 5 8
get_data_specs(x_train)
#> $labels
#> [1] "Ozone" "Solar.R" "Wind" "Temp" "Month" "Day"
#>
#> $classes
#> Ozone Solar.R Wind Temp Month Day
#> "numeric" "numeric" "numeric" "factor" "numeric" "numeric"
#>
#> $factor_levels
#> $factor_levels$Ozone
#> NULL
#>
#> $factor_levels$Solar.R
#> NULL
#>
#> $factor_levels$Wind
#> NULL
#>
#> $factor_levels$Temp
#> [1] "59" "62" "65" "67" "72" "74"
#>
#> $factor_levels$Month
#> NULL
#>
#> $factor_levels$Day
#> NULL
#>
#>