preyas patel
preyas patel

Reputation: 11

AttributeError: 'function' object has no attribute 'keys'

#Load dataset
from sklearn.datasets import load_breast_cancer
data = load_breast_cancer

When I run below command

data.keys()

It shows an error like this

AttributeError Traceback (most recent call last) in () ----> 1 data.keys()

AttributeError: 'function' object has no attribute 'keys'

Upvotes: 0

Views: 4965

Answers (1)

funie200
funie200

Reputation: 3908

load_breast_cancer is a function. With:

data = load_breast_cancer

You assign the function load_breast_cancer to the variable data, making the variable data refer to the function load_breast_cancer. If you want to get the data that the load_breast_cancer function returns and put it in the variable data, you have to call it like so:

data = load_breast_cancer()

Upvotes: 4

Related Questions