While predict we are getting error AttributeError: 'numpy.ndarray' object has no attribute 'predict'


Github link : git@github.com:pawaravinash0007/MachineLearning.git
streamlit deployment link : Streamlit

Dear All,
We are getting attribute errors
AttributeError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs (if you’re on Streamlit Cloud, click on ‘Manage app’ in the lower right of your app).

File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
    exec(code, module.__dict__)File "/mount/src/machinelearning/app.py", line 22, in <module>
    result = clf.predict(np.array([[sepal_l, sepal_w, petal_l, petal_w]]))
Traceback (most recent call last):
  File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
    exec(code, module.__dict__)
  File "/mount/src/machinelearning/app.py", line 22, in <module>
    result = clf.predict(np.array([[sepal_l, sepal_w, petal_l, petal_w]]))
AttributeError: 'numpy.ndarray' object has no attribute 'predict'

please suggest the best resolution.
Heartly Thank you in advance
Avinash

Hi,
Could you try modifying

to be:

result = clf.predict([[sepal_l, sepal_w, petal_l, petal_w]])

or

result = clf.predict(np.array([sepal_l, sepal_w, petal_l, petal_w]))

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.