2

I would like to utilize shap values for multivariate time series data and models like prophet.

from prophet import Prophet
ph = Prophet()

for column in time_series_df.drop(columns = ['y', 'ds'], inplace = False).columns:
    ph.add_regressor(column, standardize='auto', mode = 'additive')
ph.add_country_holidays('US')

ph.fit(time_series_df)

I now want to, utilize dalex (or shap) to get the shape values

import dalex
def predict_function(model, data):
    return model.predict(data)['yhat'].to_numpy()

dalex_ex = dalex.Explainer(ph, ph_train, label = 'y', predict_function = predict_function)

But it throws the following error:

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''

Is there a way how to handel data-time data better for those kind of algorithms?

Bara
  • 129
  • 5
  • 1
    This won't anwser your question, but you can check regressor "importance" with coef. regressor_coefficients(model), more info can be found on prophet github page. – Gedas Miksenas Apr 14 '22 at 09:56
  • `Explainer` has pretty limited number of models it can explain. Use `KernelExplainer` instead. – Sergey Bushmanov Apr 14 '22 at 14:12
  • The Problem stays the same. I think the issue is that shap can not handle datetimevalues. This is were I am trying to find a solution for. – Bara Apr 14 '22 at 16:00
  • @Bara the undelying model treats datetimes like `_since_arbitrary_date` -- like an integer. Perhaps the solution involves using the `KernelExplainer` and some sort of two-way conversion from datetime to integer before feeding to SHAP. – generic_user Dec 02 '22 at 22:29

0 Answers0