Skip to contents

Extract and formats the 1D attribution basis from the provided local explanation.

Usage

sug_basis(attr_df, rownum)

Arguments

attr_df

A data frame of local explanation attributions.

rownum

The rownumber of the observation. Typically primary or comparison observations.

Value

A matrix of the 1D basis.

Examples

library(cheem)

## Attribution basis of the primary instance
sug_basis(ames_rf_shap, rownum = 1)
#>              data.frame
#> LotArea      0.85497616
#> OverallQual  0.21436882
#> YearBuild    0.05907171
#> LivingArea   0.42354666
#> Bathrms     -0.02586855
#> Bedrms       0.01659048
#> TotRms       0.05857403
#> GarageYrBlt  0.08939046
#> GarageArea   0.16677691


## This can be used to find a basis to start the radial tour.
# ?radial_cheem_tour

## Regression setup:
dat  <- amesHousing2018_NorthAmes
X    <- dat[, 1:9]
Y    <- dat$SalePrice
clas <- dat$SubclassMS

## radial_cheem_tour()
ames_rf_chm <- cheem_ls(X, Y, ames_rf_shap, ames_rf_pred, clas,
                        label = "North Ames, RF, SHAP")
bas <- sug_basis(ames_rf_shap, 1)
mv  <- sug_manip_var(ames_rf_shap, 1, 2)
ggt <- radial_cheem_tour(ames_rf_chm, basis = bas, manip_var = mv)
if(interactive()){
  ## As a plotly html widget
  spinifex::animate_plotly(ggt)
  
  ## As a gganimation
  spinifex::animate_gganimate(ggt, render = gganimate::av_renderer())
}
## radial_cheem_tour is also used in: ?run_app()