File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
optuna/visualization/matplotlib Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -175,7 +175,12 @@ def _calculate_axis_data(
175175 returned_values : Sequence [int | float ]
176176 if axis .is_cat :
177177 enc = _LabelEncoder ()
178- returned_values = enc .fit_transform (list (map (str , values )))
178+ # Fit LabelEncoder with all the categories in categorical distribution.
179+ enc .fit (list (map (str , filter (lambda value : value is not None , axis .values ))))
180+ # Then transform the values using the fitted label encoder.
181+ # Note that `values` may not include all the categories,
182+ # so we use `axis.values` for fitting.
183+ returned_values = enc .transform (list (map (str , values )))
179184 cat_param_labels = enc .get_labels ()
180185 cat_param_pos = enc .get_indices ()
181186 else :
You can’t perform that action at this time.
0 commit comments