mljar / mljar-supervised

Python package for AutoML on Tabular Data with Feature Engineering, Hyper-Parameters Tuning, Explanations and Automatic Documentation
https://mljar.com
MIT License
3k stars 401 forks source link

TypeError: Object of type 'uint8' is not JSON serializable #277

Closed pplonski closed 3 years ago

pplonski commented 3 years ago

Dataset: car-evaluation (1728, 21) from https://github.com/pplonski/SmallDataBenchmarks

Object of type 'uint8' is not JSON serializable
Traceback (most recent call last):
  File "/home/piotr/sandbox/mljar-supervised/supervised/base_automl.py", line 907, in _fit
    trained = self.train_model(params)
  File "/home/piotr/sandbox/mljar-supervised/supervised/base_automl.py", line 303, in train_model
    mf.save(model_path)
  File "/home/piotr/sandbox/mljar-supervised/supervised/model_framework.py", line 355, in save
    fout.write(json.dumps(desc, indent=4))
  File "/usr/lib/python3.6/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/usr/lib/python3.6/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/usr/lib/python3.6/json/encoder.py", line 430, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/usr/lib/python3.6/json/encoder.py", line 404, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.6/json/encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "/usr/lib/python3.6/json/encoder.py", line 404, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.6/json/encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "/usr/lib/python3.6/json/encoder.py", line 404, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.6/json/encoder.py", line 404, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.6/json/encoder.py", line 404, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.6/json/encoder.py", line 325, in _iterencode_list
    yield from chunks
  File "/usr/lib/python3.6/json/encoder.py", line 437, in _iterencode
    o = _default(o)
  File "/usr/lib/python3.6/json/encoder.py", line 180, in default
    o.__class__.__name__)
TypeError: Object of type 'uint8' is not JSON serializable
bertop89 commented 3 years ago

Same here!

pplonski commented 3 years ago

It is some problem with encoding categorical values. Probably during saving categorical encoder details into a file.

pplonski commented 3 years ago

There was a problem because the AutoML system can't recognize uint as discrete.

pplonski commented 3 years ago

Will be in 0.7.19 release.