Skip to content
Advertisement

AttributeError: ‘dict’ object has no attribute ‘data’

An error occurred while executing the KNN algorithm. I don’t know where the error occurred. Can anyone help me? Please. There is a code below. I don’t know why, but the code was cut.

JavaScript

Advertisement

Answer

One line defines:

JavaScript

That’s a dict comprehension statement

In the next loop you have

JavaScript

It’s that use of .data that’s giving problem. With a dict have access values with

JavaScript

syntax, not with the attribute syntax.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement