interpretml / interpret

Fit interpretable models. Explain blackbox machine learning.
https://interpret.ml/docs
MIT License
6.28k stars 729 forks source link

Example of an interaction term from GA2M (a.k.a. EBM)? #2

Closed dfrankow closed 5 years ago

dfrankow commented 5 years ago

GAMs are non-linear terms per feature, combined in a linear way. GA2Ms also include pairwise interactions, chosen in a heuristically efficient way with FAST.

If I use an explainable boosting classifier/regressor, how can I tell whether it considered interaction terms?

Can you document an example where interaction terms are used, including graphs?

Thanks.

dfrankow commented 5 years ago

By the way, how do you pronounce "GA2M"? My colleague has taken to calling them "interaction GAMs" because it's pronounceable.

interpret-ml commented 5 years ago

Hi dfrankow,

Good questions! We can train interaction terms (and detect significant interactions with FAST) in this codebase. We're still working on optimizing the training speed for pairs, so in some cases, they may take a fair bit longer than main effects to train.

You can include interactions by using the "interactions" parameter when you initialize the ExplainableBoostingClassifier/Regressor: ebm = ExplainableBoostingClassifier(interactions=5, random_state=42) and then you can call ebm.fit(X_train, y_train) like usual.

If you pass "interactions" an integer n (ex: interactions=5), we will run FAST and automatically detect the "top-n" pairs, and include them in the training process. Alternatively, you can pass in a list of list of integers (ex: interactions=[[2,3],[4,5]]) which will force the algorithm to learn pairs on features 2/3 and features 4/5.

We pronounce GA2M character by character: G-A-2-M (gee-ay-two-emm).

dfrankow commented 5 years ago

How do you visualize the heatmap of the interaction features?

Here is my code to visualize features:

explanation = ebc.explain_global()
for feature_idx in range(num_features):
    iplot(explanation.visualize(feature_idx))

It doesn't show any interaction features.

dfrankow commented 5 years ago

in fact, how can i tell what the interactions are, or that they were even computed?

interpret-ml commented 5 years ago

For our current design, we add the learned interaction terms to the ebm's "feature_names" property, at the end of the initial set of features. So instead of iterating through range(num_features), try this:

for feature_idx in range(len(ebc.feature_names)):
    iplot(explanation.visualize(feature_idx))

The interaction feature names are combinations of the original feature names (ex: 'Age' and 'Height' might create a new feature, 'Age x Height'). You can easily see what interactions are learned by checking ebc.feature_names (it's just a standard Python list).

The "show" method typically handles this natively, so hopefully our soon-to-release fix for it will work for you. Otherwise, it takes a slight bit more effort to use the iplot() interface with things like pairs.

dfrankow commented 5 years ago

Great, thank you!

dfrankow commented 5 years ago

Knowing how to use it is 90%. Having interface around might be nice, but I really appreciate your willingness to answer questions!

dfrankow commented 5 years ago

I can see and plot an interaction term, so I consider this closed.

xiaohk commented 3 years ago

Hey @dfrankow, thank you so much for using GAM, GA2M, and EBM! I am Jay Wang, a research intern at the InterpretML team. We are developing a new visualization tool for EBM and recruiting participants for a user study (see #283 for more details).

We think you are a good fit for this paid user study! If you are interested, you can sign up with the link in #283. Let me know if you have any question. Thank you!