close

[Solved] ‘numpy.ndarray’ object has no attribute ‘values’

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error ‘numpy.ndarray’ object has no attribute ‘values’ in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How ‘numpy.ndarray’ object has no attribute ‘values’ Error Occurs?

Today I get the following error ‘numpy.ndarray’ object has no attribute ‘values’ in python.

How To Solve ‘numpy.ndarray’ object has no attribute ‘values’ Error ?

  1. How To Solve 'numpy.ndarray' object has no attribute 'values' Error ?

    To Solve 'numpy.ndarray' object has no attribute 'values' Error y_train is of type numpy.ndarray and, as staded on the error message

  2. 'numpy.ndarray' object has no attribute 'values'

    To Solve 'numpy.ndarray' object has no attribute 'values' Error y_train is of type numpy.ndarray and, as staded on the error message

Solution 1

I had the same error but this worked

random_forest.fit(X_train,y_train.ravel())

Solution 2


On the line

mlp.fit(X_train, y_train.values.ravel())

y_train is of type numpy.ndarray and, as staded on the error message

has no attribute ‘values’

If you have properly encoded this array, you should be able to use it simply as

mlp.fit(X_train, y_train)

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read