Type mismath in ch5/tox21_rf.py under python3
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 322
- Forks
- 155
- PR merge metrics
- No merged PRs in 30d
Description
`python3 ch5/tox21_rf.py` outputs:
```
About to fit model on train set.
Traceback (most recent call last):
File "tox21_rf.py", line 25, in
sklearn_model.fit(train_X, train_y)
File "/home/alexander/env/tf/lib/python3.8/site-packages/sklearn/ensemble/_forest.py", line 330, in fit
y, expanded_class_weight = self._validate_y_class_weight(y)
File "/home/alexander/env/tf/lib/python3.8/site-packages/sklearn/ensemble/_forest.py", line 558, in _validate_y_class_weight
check_classification_targets(y)
File "/home/alexander/env/tf/lib/python3.8/site-packages/sklearn/utils/multiclass.py", line 172, in check_classification_targets
raise ValueError("Unknown label type: %r" % y_type)
ValueError: Unknown label type: 'unknown'
```
It helps to replace line 14:
```
train_y = train_y[:, 0]
```
with
```
train_y = train_y[:, 0].astype('int')
```
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open ch5/tox21_rf.py and inspect line 14, where train_y is prepared before sklearn_model.fit. Run `python3 ch5/tox21_rf.py` before and after the change; done means the training step proceeds without the reported Unknown label type error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, scikit-learn
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100