Skip to content

lightgbm/predict-disabled-shape-check

Rule predict-disabled-shape-check
Pack LightGBM
Severity warning
Fix unsafe, with xpd check --fix --unsafe-fixes
Library versions every version

LightGBM's prediction engine normally checks that the number of features matches training. With predict_disable_shape_check=True, mismatched input can yield incorrect predictions. Some estimator inputs also go through a separate scikit-learn check before they reach the engine.

booster.predict(features, predict_disable_shape_check=True)
booster.predict(features, validate_features=True)

Supply the features in training order and keep the count check enabled. For a pandas DataFrame, validate_features=True also checks the feature names against training. The example assumes a pandas DataFrame.

The unsafe fix sets the flag to False. This restores the check for a Booster, an estimator, or a CVBooster. Calls that relied on mismatched inputs may then raise until you fix their feature schema.

Prediction parameters | Booster prediction API

xpd prints this message with the issue. A name that starts with $ stands for code from your file.

This flag bypasses LightGBM's feature-count check in the prediction engine. Keep the check enabled and pass features in training order.

Browse the other rules of the LightGBM pack.