You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
***Plots or saves the shape of a given unique term affiliation. For main effects, it produces a line plot. For two-way interactions, it produces a heatmap. Plotting for higher-order interactions is not supported. This method provides a convenient way to visualize model components.***
379
+
380
+
### Parameters
381
+
382
+
#### affiliation
383
+
A string specifying which unique_term_affiliation to use.
384
+
385
+
#### plot (default = True)
386
+
If True, displays the plot.
387
+
388
+
#### save (default = False)
389
+
If True, saves the plot to a file.
390
+
391
+
#### path (default = "")
392
+
The file path to save the plot. If empty and save is True, a default path will be used, for example "shape_of_my_predictor.png".
393
+
394
+
376
395
## Method: remove_provided_custom_functions()
377
396
378
397
***Removes any custom functions provided for calculating the loss, negative gradient, or validation error. This is useful after model training with custom functions, ensuring that the APLRRegressor object no longer depends on these functions—so they do not need to be present in the Python environment when loading a saved model.***
Copy file name to clipboardExpand all lines: documentation/model_interpretation_for_classification.md
+6-1Lines changed: 6 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,5 +3,10 @@
3
3
## Feature importance
4
4
Use the ***get_feature_importance*** method as shown in this [example](https://github.com/ottenbreit-data-science/aplr/blob/main/examples/train_aplr_classification.py).
5
5
6
+
## Local feature contribution
7
+
Use the ***calculate_local_feature_contribution*** method, for example on test data or new data. Usage of this method is demonstrated in this [example](https://github.com/ottenbreit-data-science/aplr/blob/main/examples/train_aplr_classification.py).
8
+
6
9
## Main effects and interactions
7
-
For best interpretability of interactions, do not use a higher ***max_interaction_level*** than 1. Use the ***calculate_local_feature_contribution*** method to interpret main effects and interactions as shown in this [example](https://github.com/ottenbreit-data-science/aplr/blob/main/examples/train_aplr_classification.py). You may also use the ***get_logit_model*** method to access the underlying APLR regression models as shown in this [example](https://github.com/ottenbreit-data-science/aplr/blob/main/examples/train_aplr_classification.py). You can interpret these models in the same way as described in this [example](https://github.com/ottenbreit-data-science/aplr/blob/main/examples/train_aplr_regression.py).
10
+
For each category, you can interpret the main effects and interactions of its underlying logit model. For best interpretability of interactions, do not use a higher ***max_interaction_level*** than 1.
11
+
12
+
A convenient way to visualize the model components is to first use the ***get_logit_model*** method to access the underlying `APLRRegressor` model for a specific category. Then, you can use the ***plot_affiliation_shape*** method on that logit model to generate plots for its main effects (line plots) and two-way interactions (heatmaps). This is demonstrated in this [example](https://github.com/ottenbreit-data-science/aplr/blob/main/examples/train_aplr_classification.py).
Copy file name to clipboardExpand all lines: documentation/model_interpretation_for_regression.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,10 +7,10 @@ Use the ***get_feature_importance*** method as shown in this [example](https://g
7
7
Use the ***calculate_feature_importance*** method or the ***calculate_local_feature_contribution*** method, for example on test data or new data. Usage of these methods is demonstrated in this [example](https://github.com/ottenbreit-data-science/aplr/blob/main/examples/train_aplr_regression.py).
8
8
9
9
## Main effects
10
-
Use the ***get_main_effect_shape*** method or the ***get_unique_term_affiliation_shape*** method to interpret main effects as shown in this [example](https://github.com/ottenbreit-data-science/aplr/blob/main/examples/train_aplr_regression.py). For each main effect, you may plot the output in a line plot.
10
+
Use the ***plot_affiliation_shape*** method to easily plot main effects, as shown in this [example](https://github.com/ottenbreit-data-science/aplr/blob/main/examples/train_aplr_regression.py). Alternatively, use the ***get_main_effect_shape*** or ***get_unique_term_affiliation_shape*** methods to get the data for a custom plot.
11
11
12
12
## Interactions
13
-
For best interpretability of interactions, do not use a higher ***max_interaction_level*** than 1. Use the ***get_unique_term_affiliation_shape*** method to interpret interactions as shown in this [example](https://github.com/ottenbreit-data-science/aplr/blob/main/examples/train_aplr_regression.py). For each two-way interaction of interest you may plot the output in a 3D surface plot.
13
+
For best interpretability of interactions, do not use a higher ***max_interaction_level*** than 1. Use the ***plot_affiliation_shape*** method to easily plot two-way interactions as a heatmap, as shown in this [example](https://github.com/ottenbreit-data-science/aplr/blob/main/examples/train_aplr_regression.py). Alternatively, use the ***get_unique_term_affiliation_shape*** method to get the data for a custom plot, for example a 3D surface plot.
14
14
15
15
## Interpretation of model terms and their regression coefficients
16
16
The above interpretations of main effects and interactions are sufficient to interpret an APLR model. However, it is possible to also inspect the underlying terms for those who wish to do so. For an example on how to interpret the terms in an APLR model, please see ***Section 5.1.3*** in the published article about APLR. You can find this article on [https://link.springer.com/article/10.1007/s00180-024-01475-4](https://link.springer.com/article/10.1007/s00180-024-01475-4) and [https://rdcu.be/dz7bF](https://rdcu.be/dz7bF).
# Generate and save plots of main effects and two-way interactions for each category. This is probably the most useful method for model interpretation.
Copy file name to clipboardExpand all lines: examples/train_aplr_classification_using_aplr_tuner.py
+12-2Lines changed: 12 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -86,10 +86,20 @@
86
86
by="importance", ascending=False
87
87
)
88
88
89
+
# Generate and save plots of main effects and two-way interactions for each category. This is probably the most useful method for model interpretation.
0 commit comments