Error running demo/guide-python/categorical.py: ValueError: Invalid classes inferred from unique values of `y`. Expected: [0 1 2], got [ 0. 1. nan]
- Dominant language
- C++
- Stars
- 28.8k
- Forks
- 8.9k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 54
Description
xgboost 1.6.0+
Run this file: https://github.com/dmlc/xgboost/blob/master/demo/guide-python/categorical.py
Output:
```
train data set has got 143246 rows and 25 columns
train data set has got 143246 rows and 24 columns
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
[](https://localhost:8080/#) in ()
118 with TemporaryDirectory() as tmpdir:
119 start = time()
--> 120 categorical_model(X, y, tmpdir)
121 end = time()
122 print("Duration:categorical", end - start)
2 frames
[/usr/local/lib/python3.10/dist-packages/xgboost/sklearn.py](https://localhost:8080/#) in fit(self, X, y, sample_weight, base_margin, eval_set, eval_metric, early_stopping_rounds, verbose, xgb_model, sample_weight_eval_set, base_margin_eval_set, feature_weights, callbacks)
1355 or not (self.classes_ == expected_classes).all()
1356 ):
-> 1357 raise ValueError(
1358 f"Invalid classes inferred from unique values of `y`. "
1359 f"Expected: {expected_classes}, got {self.classes_}"
ValueError: Invalid classes inferred from unique values of `y`. Expected: [0 1 2], got [ 0. 1. nan]
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.