Skip to content

Regression Example #33

@joshualeond

Description

@joshualeond

Hi Thomas, thanks for your work here! I wanted to test the regression functionality similar to the python lime example here.

Everything seems to work correctly until the call to explain. Here is my reprex:

library(caret)
#> Loading required package: lattice
#> Loading required package: ggplot2
library(lime)

# load data
boston <- MASS::Boston

# Split up the data set
boston_test <- boston[1:100, 1:13]
boston_train <- boston[-(1:100), 1:13]
boston_lab <- boston[[14]][-(1:100)]

# Create Random Forest model on boston data
model_reg <- train(boston_train, boston_lab, method = 'rf')
#> randomForest 4.6-12
#> Type rfNews() to see new features/changes/bug fixes.
#> 
#> Attaching package: 'randomForest'
#> The following object is masked from 'package:ggplot2':
#> 
#>     margin

# Create an explainer object
explainer_reg <- lime(boston_train, model_reg)

# Explain new observation
explanation_reg <- explain(
  boston_test, 
  explainer_reg, 
  labels = NULL, 
  n_labels = 1, 
  n_features = 5
  )
#> Warning in explain.data.frame(boston_test, explainer_reg, labels = NULL, :
#> "labels" and "n_labels" arguments are ignored when explaining regression
#> models
#> Error in y[1, ]: incorrect number of dimensions

I may be missing something obvious but I haven't discovered it yet. Also as a note, if I attempt to leave the labels and n_labels arguments out of the function call it throws an error. Thanks again.

Metadata

Metadata

Assignees

Labels

bugan unexpected problem or unintended behavior

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions