Skip to content

'Expecting data to be a DMatrix object, got: ', <class 'pandas.core.frame.DataFrame'> #498

Description

@yzheng27

Was following example https://github.com/interpretml/interpret-community/blob/master/notebooks/explain-regression-local.ipynb on my own data and xgboost object, but get error ('Expecting data to be a DMatrix object, got: ', <class 'pandas.core.frame.DataFrame'>) at explainer.explain_global(x_test). Changed x_test to DMatrix generates error 'DMatrix' object has no attribute 'shape'. Please advise. Thank you.

x_train, x_test, y_train, y_test = train_test_split(df[features], df[LABEL], test_size=0.2, random_state=0)

from interpret.ext.blackbox import TabularExplainer
explainer = TabularExplainer(model, 
                             x_train, 
                             model_task = 'regression',
                             features=features)
global_explanation = explainer.explain_global(x_test)
# xgtest = xgb.DMatrix(x_test.values)
# global_explanation = explainer.explain_global(xgtest)

Version:
interpret-community==0.23.0
interpret-core==0.2.7
xgboost==1.4.1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions