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

**URL:** <https://discuss.streamlit.io/t/while-predict-we-are-getting-error-attributeerror-numpy-ndarray-object-has-no-attribute-predict/66055>\
**Category:** Community Cloud\
**Tags:** streamlit-cloud, discussion\
**Created:** [April 2, 2024, 6:02am UTC](https://discuss.streamlit.io/t/while-predict-we-are-getting-error-attributeerror-numpy-ndarray-object-has-no-attribute-predict/66055 "2024-04-02T06:02:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AVINASH\_PAWAR](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/avinash_pawar/32/40974_2.png) [@AVINASH\_PAWAR](https://discuss.streamlit.io/u/AVINASH_PAWAR)\
**Post date:** [April 2, 2024, 6:02am UTC](https://discuss.streamlit.io/t/while-predict-we-are-getting-error-attributeerror-numpy-ndarray-object-has-no-attribute-predict/66055/1 "2024-04-02T06:02:07Z")

</div>

![a](https://global.discourse-cdn.com/streamlit/original/3X/0/9/09f69f1313f371cc040e555afd673a340e16a79b.jpeg)  
Github link : [git@github.com](mailto:git@github.com):pawaravinash0007/MachineLearning.git  
streamlit deployment link : [Streamlit](https://aviapp.streamlit.app/)

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).

```auto
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]]))

```

```auto
Traceback (most recent call last):

```

```auto
  File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script

```

```auto
    exec(code, module. __dict__ )

```

```auto
  File "/mount/src/machinelearning/app.py", line 22, in <module>

```

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

```

```auto
AttributeError: 'numpy.ndarray' object has no attribute 'predict'

```

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

---

<div class="post-metadata">

**Author:** ![dataprofessor](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/dataprofessor/32/44163_2.png) [@dataprofessor](https://discuss.streamlit.io/u/dataprofessor)\
**Post date:** [April 5, 2024, 4:57am UTC](https://discuss.streamlit.io/t/while-predict-we-are-getting-error-attributeerror-numpy-ndarray-object-has-no-attribute-predict/66055/2 "2024-04-05T04:57:40Z")

</div>

Hi,  
Could you try modifying

> [@AVINASH\_PAWAR](#):
>
> `result = clf.predict(np.array([[sepal_l, sepal_w, petal_l, petal_w]]))`

to be:

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

```

or

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

```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/streamlit/original/3X/c/f/cf4c2ee0d938358f82448c5fe4b9c3c91d7ce19c.svg) [@system](https://discuss.streamlit.io/u/system)\
**Post date:** [October 2, 2024, 4:58am UTC](https://discuss.streamlit.io/t/while-predict-we-are-getting-error-attributeerror-numpy-ndarray-object-has-no-attribute-predict/66055/3 "2024-10-02T04:58:34Z")

</div>

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