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

Add possibility of using multiple models #467

Open
montanarograziano opened this issue Jul 18, 2023 · 2 comments
Open

Add possibility of using multiple models #467

montanarograziano opened this issue Jul 18, 2023 · 2 comments

Comments

@montanarograziano
Copy link

montanarograziano commented Jul 18, 2023

Description of Problem:
Sometimes multiple models are trained
(on the same dataset, based on some criteria/conditions (e.g. dataset is too big to train a single model, or there is too much variability in the data). Currently, the SmartExplainer object accept a single model, meaning that multiple SmartExplainer objects must be created to address this problem and therefore multiple apps. Would this be a useful scenario of someone?

Overview of the Solution:
Add the possibility of passing a list of models instead of a single one to the SmartExplainer constructor and configure their usage based on a list of conditions.

Examples:
Something like this:

xpl = SmartExplainer(
    models=[model1, model2, model3],
    features_dict=features_dict,
    conditions=[df['avg'] >= 20, df['avg'] > (20 & df['avg'] <= 50), (df['avg'] > 50 & df['avg'] < 100)]
)

Blockers:

Definition of Done:

@ThomasBouche
Copy link
Collaborator

Hi,
Thanks for your issue,

This type of use is interesting. But development may not be straightforward.

Contributions can be compiled into a single webapp. several steps are required to compile models individually, then aggregate them.
You have to do something like this:

Compute your contributions

xpl1 = SmartExplainer(models=model1)
xpl1.compile(Xtest1)

xpl2 = SmartExplainer(models=model2)
xpl2.compile(Xtest2)

Then concat your contributions

#for regression
df_contributions = pd.concat([xpl1.contributions, xpl2.contributions],axis=0)
#for classification, you have to concat each class
df_contributions = [pd.concat([xpl1.contributions[0], xpl2.contributions[0]],axis=0),
    pd.concat([xpl1.contributions[1], xpl2.contributions[1]],axis=0)]

And give this contributions to a new shapash, if you give your contribution, you can give any model accept by shapash.
You can also give an additionnal dataset with your feature 'avg' to filter in the webapp

xpl_all = SmartExplainer(models=model1)
xpl_all.compile(
 Xtest_all,
 contributions = df_contributions,
 additional_data=X_additional
)

I hope this solution works until there is a more appropriate development for this type of use.

@montanarograziano
Copy link
Author

Thank you for your response, this is exactly the solution I adopted temporarily for my use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants