Takes a matrix of class vivid and turn it into a data frame containing variable names, Vimp and Vint values, and the row and column index from the original matrix.

# S3 method for vivid
as.data.frame(x, row.names = NULL, optional = FALSE, ...)

Arguments

x

A matrix of class 'vivid' to be converted to a data frame.

row.names

NULL or a character vector giving the row names for the data frame. Missing values are not allowed.

optional

Logical. If TRUE, setting row names and converting column names (to syntactic names: see make.names) is optional. Note that all of R's base package as.data.frame() methods use optional only for column names treatment, basically with the meaning of data.frame(*, check.names = !optional). See also the make.names argument of the matrix method.

...

Additional arguments to be passed to or from methods.

Value

A data frame of Vimp and Vint values and their index from the vivid matrix.

Examples

 # \donttest{
library(ranger)
aq <- na.omit(airquality)
aq <- aq[1:20,]# for speed
rF <- ranger(Ozone ~ ., data = aq, importance = "permutation")
myMat <- vivi(fit = rF, data = aq, response = "Ozone")
#> Agnostic variable importance method used.
#> Calculating interactions...
myDf <- as.data.frame(myMat)
myDf
#>    Variable_1 Variable_2     Value Measure Row Col
#> 1     Solar.R    Solar.R 3.4550141    Vimp   1   1
#> 2         Day    Solar.R 0.5226910    Vint   2   1
#> 3        Temp    Solar.R 0.2842148    Vint   3   1
#> 4        Wind    Solar.R 0.2063291    Vint   4   1
#> 5       Month    Solar.R 0.0000000    Vint   5   1
#> 6     Solar.R        Day 0.5226910    Vint   1   2
#> 7         Day        Day 2.6768169    Vimp   2   2
#> 8        Temp        Day 0.2555597    Vint   3   2
#> 9        Wind        Day 0.2907211    Vint   4   2
#> 10      Month        Day 0.0000000    Vint   5   2
#> 11    Solar.R       Temp 0.2842148    Vint   1   3
#> 12        Day       Temp 0.2555597    Vint   2   3
#> 13       Temp       Temp 0.7854735    Vimp   3   3
#> 14       Wind       Temp 0.2663974    Vint   4   3
#> 15      Month       Temp 0.0000000    Vint   5   3
#> 16    Solar.R       Wind 0.2063291    Vint   1   4
#> 17        Day       Wind 0.2907211    Vint   2   4
#> 18       Temp       Wind 0.2663974    Vint   3   4
#> 19       Wind       Wind 2.1653009    Vimp   4   4
#> 20      Month       Wind 0.0000000    Vint   5   4
#> 21    Solar.R      Month 0.0000000    Vint   1   5
#> 22        Day      Month 0.0000000    Vint   2   5
#> 23       Temp      Month 0.0000000    Vint   3   5
#> 24       Wind      Month 0.0000000    Vint   4   5
#> 25      Month      Month 0.0000000    Vimp   5   5
# }