Skip to content

On-premise users: click in-app to access the full platform documentation for your version of DataRobot.

Constraints (monotonic)

In some projects (typically insurance and banking), you may want to force the directional relationship between a feature and the target (for example, higher home values should always lead to higher home insurance rates). By training with monotonic constraints, you force certain XGBoost models to learn only monotonic (always increasing or always decreasing) relationships between specific features and the target. For example, increasing values in feature(s) that describe the value of the home have an always increasing relationship with the target, claim losses. You set the direction of the relationships—increasing or decreasing— by creating feature lists and applying them in Advanced options > Feature Constraints. You can also create lists and retrain models from the Leaderboard menu after the initial model run.

General workflow

Typically, working with monotonic constraints follows the workflow described below. Review the modeling considerations before starting, including special considerations for time series projects.

  1. Create feature lists for monotonically increasing and/or monotonically decreasing constraints.

  2. Set the target and the modeling feature list.

  3. From the Advanced options link, configure feature constraints.

  4. Start the model build using any of the modeling modes.

  5. When model building finishes, investigate the results.

  6. (Optional) Retrain model(s) using different monotonic constraints (or without constraints).

  7. Compare training results between models using the Feature Effects partial dependence graph to help with final model selection.

Create feature lists

The first step in monotonic modeling is to create feature lists that identify monotonically constrained features. The feature(s) contained in these list(s) are those that have a forced directional relationship, increasing or decreasing, with the target. Note that use of monotonic feature lists does not replace the standard model building feature list. Instead, these lists identify features in the selected model building feature list that should be handled differently.

When creating lists, remember:

  • Features must be of type numeric, percentage, length, or currency.
  • There can be no feature overlap in the feature lists for monotonically increasing and monotonically decreasing constraints.
  • After creating lists, be sure to change the Feature List dropdown to the list for the project model build (otherwise, it remains on the last created list).
  • The target feature is automatically added to every feature list.

Evaluate results

When model building is complete, there are several tools for investigating and evaluating the results. First, check the Leaderboard to identify the model(s) that are, or can be, trained with monotonic constraints (identified with the MONO badge). To determine if a model was built with constraints, check the Leaderboard model description.

Expand a constrained model and, from the Describe > Constraints tab, review the features that were constrained:

There are cases where some, or all, of the features identified in the constraint list were not used in the final modeling feature list. This happens, for example, when DataRobot creates a reduced feature list for the recommended model. In essence, this also serves as a constraint.

Next, calculate and view the Feature Effects partial dependence graph, checking the results for monotonically constrained features. This graph helps determine whether a monotonically constrained feature maintains the monotonic relationship with the predicted target. Partial dependence is calculated, based on the validation set, between each predictor and predicted target values—it calculates the relationship between average target values and predictor values of each bin. Since impacts from other predictors on predicted target values tend to be averaged out, partial dependence reflects the relationship between an individual predictor and the target. If a model is trained with monotonic constraints, the relationship between monotonically constrained features and predicted target tends to be monotonic.

For example, this graph plots partial dependence on a model trained without constraints:

When monotonically decreasing constraints are applied, partial dependence looks more like this:

Retrain models with new constraints

You may decide, after a model build, to change the monotonic feature list and rerun one or more models. To do this:

  1. From the Leaderboard, select models that support constraints by checking the box to the left of the model name. Click the MONO badge to filter the Leaderboard display so that it shows only eligible models.

  2. Expand the menu and select Run Selected Model(s) with Constraints. Note that this option is only available if all selected models support constraints.

  3. In the upper part of the screen, the window expands and provides a dropdown for selecting monotonic increasing and decreasing feature lists.

  4. Once set, click Run Models.

Feature considerations

The following considerations apply to monotonic modeling.

  • Blenders that contain monotonic models do not display the MONO label on the Leaderboard.

  • Monotonic modeling is available in binary classification and regression projects.

  • Monotonic constraints can only be applied between Numeric, Percentage, Length, or Currency type variables and the target.

  • Generalized Additive Models, Frequency/Severity, and Frequency/Cost models don't support interactions with features trained with monotonic constraints.

  • Only Extreme Gradient Boosted Trees, Generalized Additive Models and Frequency/Severity (both frequency and severity model based on XGBoost) and Frequency/Cost model (both frequency and cost model based on XGBoost) support training with monotonic constraints.

  • Extreme Gradient Boosted Trees that include Search for differences tasks (i.e., DIFF3), Search for ratio tasks (i.e., RATIO3) don’t support training with monotonic constraints. (This is because these tasks tend to change the monotonic correlation between features and predicted target.)

  • Constraints for models used by Autopilot or from the Repository can only be set in advanced options and can't be changed after a project is created.

  • New constraints can only be set for models on the Leaderboard.

  • If Include only monotonic models is selected in advanced options, Autopilot only runs the average blender.

  • When using monotonic constraints with time series projects:

    • Only XGB models are supported
    • Prior to the feature derivation process (i.e., monotonic lists added before EDA2), features used for monotonicity will be set as "do not derive."
    • When there is an offset in the blueprint, for example naive predictions, the predictions themselves may not be monotonic after offset is applied. (XGBoost does honor monotonicity.)
    • If the model is a collection of models (per-series XGBoost or Performance Clustered blueprint, for example) monotonicity is preserved per-series/cluster.

Updated February 16, 2024
Back to top