Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does DALEX work with PyTorch models? #565

Closed
yanghuikang opened this issue May 29, 2024 · 3 comments
Closed

Does DALEX work with PyTorch models? #565

yanghuikang opened this issue May 29, 2024 · 3 comments
Labels
question ❔ Further information is requested

Comments

@yanghuikang
Copy link

I've been using DALEX to make ALE profiles for xgboost models, and recently want to test neural networks. I see that tensorflow is supported and wonder if there is a way to use it with PyTorch.

@hbaniecki
Copy link
Member

hbaniecki commented May 29, 2024

Hi, dalex will work with any model for which you can pass a predict_function to dx.Explainer. This function inputs a model with data as np.ndarray pd.DataFrame and returns a 1-dimensional np.ndarray with model predictions. Examples of such predict functions: https://github.com/ModelOriented/DALEX/blob/master/python/dalex/dalex/_explainer/yhat.py

Notably, for tensorflow, it looks like this:

def yhat_tf_regression(m, d):
    return m.predict(np.array(d), verbose=0).reshape(-1, )

def yhat_tf_classification(m, d):
    return m.predict(np.array(d), verbose=0)[:, 1]

@hbaniecki hbaniecki added the question ❔ Further information is requested label May 29, 2024
@yanghuikang
Copy link
Author

Thank you very much! I will test it with PyTorch.

@hbaniecki
Copy link
Member

reopen if needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question ❔ Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants