When performing grid search parameter tuning using model_tuner.grid_search_param_tuning(X, y), I encountered the following issue:
If X contains any zero-variance (constant) columns, the process generates multiple RuntimeWarning and UserWarning messages as shown below:
Proposed Solution:
To prevent these warnings, I suggest adding a check before the grid search process starts to identify and drop any zero-variance columns in X. This can be achieved with a simple if block like:
# Check for zero-variance columns and drop them
zero_variance_columns = X.columns[X.var() == 0]
if not zero_variance_columns.empty:
X = X.drop(columns=zero_variance_columns)
This would help avoid unnecessary warnings and improve the overall robustness of the function.
Steps to Reproduce:
Include a column in X with the same value for all rows.
Run model_tuner.grid_search_param_tuning(X, y).
Expected Behavior:
The grid search should proceed without triggering RuntimeWarning or UserWarning messages.
When performing grid search parameter tuning using
model_tuner.grid_search_param_tuning(X, y)
, I encountered the following issue:If
X
contains any zero-variance (constant) columns, the process generates multipleRuntimeWarning
andUserWarning
messages as shown below:Proposed Solution:
To prevent these warnings, I suggest adding a check before the grid search process starts to identify and drop any zero-variance columns in
X
. This can be achieved with a simple if block like:This would help avoid unnecessary warnings and improve the overall robustness of the function.
Steps to Reproduce:
Include a column in
X
with the same value for all rows. Runmodel_tuner.grid_search_param_tuning(X, y)
.Expected Behavior:
The grid search should proceed without triggering
RuntimeWarning
orUserWarning
messages.