ValueError: setting an array element with a sequence

Summary

I am trying to deploy my model but I am getting this error listed in the title.
I tried removing brackets from the list in line 110 and that didn’t work.

Steps to reproduce

Code snippet:

Traceback (most recent call last):

  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 556, in _run_script

    exec(code, module.__dict__)

  File "/app/streamlit/HealthStreamlitApp.py", line 139, in <module>

    prediction = model.predict(input_data)

  File "/home/appuser/venv/lib/python3.9/site-packages/sklearn/ensemble/_gb.py", line 1308, in predict

    raw_predictions = self.decision_function(X)

  File "/home/appuser/venv/lib/python3.9/site-packages/sklearn/ensemble/_gb.py", line 1261, in decision_function

    X = self._validate_data(

  File "/home/appuser/venv/lib/python3.9/site-packages/sklearn/base.py", line 546, in _validate_data

    X = check_array(X, input_name="X", **check_params)

  File "/home/appuser/venv/lib/python3.9/site-packages/sklearn/utils/validation.py", line 879, in check_array

    array = _asarray_with_order(array, order=order, dtype=dtype, xp=xp)

  File "/home/appuser/venv/lib/python3.9/site-packages/sklearn/utils/_array_api.py", line 185, in _asarray_with_order

    array = numpy.asarray(array, order=order, dtype=dtype)

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (29,) + inhomogeneous part.

If applicable, please provide the steps we should take to reproduce the error or specified behavior.

Expected behavior:

I expected after I pressed the button on my app that I would get a risk back.

Actual behavior:

The error message in the title.

Debug info

  • Streamlit version: 1.12.0
  • Python version: 3.9.7
  • Using Conda? =
  • OS version: Windows
  • Browser version: Chrome

Requirements file

https://github.com/AndreaHobby/streamlit/blob/main/requirements.txtpp.

Links

Additional information

If needed, add any other context about the problem here.

Hey @ah9,

Thanks for posting your question and sorry for the late response!

It looks like you resolved the array-related error you were seeing – your app appears to be running without any errors now. Cool app! :star_struck: