のねのBlog

パソコンやソフト開発で起きた問題など書きます。よろしくお願いします。

TypeError: array([[ 6.47354955]]) is not JSON serializable

エラーが出てるけど、通った。

Traceback (most recent call last):
  File "vm_main.py", line 33, in <module>
    import main
  File "/tmp/vmuser_cjxpbyuhoz/main.py", line 2, in <module>
    import studentMain
  File "/tmp/vmuser_cjxpbyuhoz/studentMain.py", line 61, in <module>
    sys.stdout.write(json.dumps(student_output))
  File "/usr/lib/python2.7/json/__init__.py", line 243, in dumps
    return _default_encoder.encode(obj)
  File "/usr/lib/python2.7/json/encoder.py", line 207, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python2.7/json/encoder.py", line 270, in iterencode
    return _iterencode(o, 0)
  File "/usr/lib/python2.7/json/encoder.py", line 184, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: array([[ 6.47354955]]) is not JSON serializable

katie's net worth prediction: [[ 160.43205453]]
slope: [[ 6.47354955]]
intercept: [-14.35378331]
 ##### stat on test dataset #####
r-squared score: 0.812365729231
 ##### stat on training dataset #####
r-squared score: 0.874588235822