> ## Content Index
> Fetch the complete content index at: https://bongholee.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Monotonic Constraint는 Prediction에 영향을 주지 않는 제약조건이다.
- URL: https://bongholee.com/monotonic-constraintneun-predictione-yeonghyangeul-juji-anhneun-jeyagjogeonida/
- Published: 2024-12-16T02:56:31.000Z
- Updated: 2024-12-16T02:56:31.000Z
- Author: Bongho Lee
- Tags: Data, #Import 2026-11-22 06:32

- +1: when the feature increases, the prediction must be greater or equal;
- 0: no monotonic constraint (default);
- \-1: when the feature increases, the prediction must be smaller or equal.
- Python Code 예

```python
decision_tree_with_constraints = DecisionTreeRegressor(  
max_depth=3,  
min_samples_leaf=10,  
monotonic_cst=[1,1] # this line of code adds monotonic constraints  
)  
  
decision_tree_with_constraints.fit(X_train, y_train)

```

```python
catboost = CatBoostRegressor(  
silent=True   )  
  
catboost_with_constraints = CatBoostRegressor(  
silent=True,  
monotone_constraints={"square feet": 1, "overall condition": 1}   )

```

- We can use CatBoost to simulate **what-if scenarios**. For example: what happens if we change the “overall condition” of houses with a square footage of respectively 500, 1,000, 2,000, or 3,000?
- This is also called **sensitivity analysis** because it measures the sensitivity of an outcome (the selling price predicted by our model) based on a change in an input variable (the house’s overall condition).

### References

- [Causality in ML Models: Introducing Monotonic Constraints](https://towardsdatascience.com/causality-in-ml-models-introducing-monotonic-constraints-8426e1b5cc34?ref=bongholee.com)