8000 BUG: 'DataFrame' object cannot be interpreted as an integer. · Issue #4013 · shap/shap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
BUG: 'DataFrame' object cannot be interpreted as an integer. #4013
Open
@bersurotterdam

Description

@bersurotterdam

Issue Description

I first got an error stating TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''. Then I changed it to numeric values and now I get this error. How can I resolve this?

Minimal Reproducible Example

X = df_encoded.drop(columns=["y", "ds", "unique_id"]) 
# Extract the best-performing model from AutoMLForecast (e.g., Ridge, LGBM, XGB)
best_model = auto_mlf.models_['lgb']  # Change this if needed

# Sample a subset of X for SHAP computation (improves speed)
X_sample = shap.utils.sample(X, 100)

# Create SHAP Explainer using AutoMLForecast model's predict function
explainer = shap.Explainer(lambda x: best_model.predict(pd.DataFrame(x, columns=X.columns)), X_sample)

# Compute SHAP values
shap_values = explainer(X)

# Plot feature importance
shap.summary_plot(shap_values, X)

Traceback

Expected Behavior

No response

Bug report checklist

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest release of shap.
  • I have confirmed this bug exists on the master branch of shap.
  • I'd be interested in making a PR to fix this bug

Installed Versions

0.47.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting feedbackIndicates that further information is required from the issue creatorbugIndicates an unexpected problem or unintended behaviour

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0