Search code examples
scikit-learnmodelrandom-forestxgboostshap

The passed model is not callable and cannot be analyzed directly with the given masker! Model: None


When i am using RandomForestRegressor or XGBoost, there is no problem like this. Since i am using Relevance Vector Regression i got this error.

from sklearn_rvm import EMRVR
model_rvr=EMRVR(kernel="linear").fit(X, y)
explainer = shap.Explainer(model_rvr)

Exception: The passed model is not callable and cannot be analyzed directly with the given masker! Model: None

Also same problem as Exception: The passed model is not callable and cannot be analyzed directly with the given masker

For Relevance Vector Regression => https://sklearn-rvm.readthedocs.io/en/latest/index.html

Any idea ?


Solution

  • I have had the same issue with a different model. The solution that worked for me was to use KernelExplainer instead of explainer. Additionally you need to use the model.predict function instead of just the model.

    So your code should be:

    from sklearn_rvm import EMRVR
    model_rvr=EMRVR(kernel="linear").fit(X, y)
    explainer = shap.KernelExplainer(model_rvr.predict, X)