저는 Python (Richart, Pedro Coelho) 도서로 Building Machine Learning Systems의 한 줄 씩의 예제를 따라 왔습니다.NameError : 이름 'labels'이 정의되지 않았습니다.
홍채 데이터 세트를 가져온 후, 우리는 나는이
>>> is_setosa = (labels == 'setosa')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'labels' is not defined
내가 생각 가지고 Setosa
data = load_iris()
features = data['data']
plength = features[:, 2]
# use numpy operations to get setosa features
is_setosa = (labels == 'setosa')
으로 사람을 추출 할 것을 그래서 나는
>>> is_setosa = plenght(labels == 'setosa')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'plenght' is not defined
>>> is_setosa = plength(labels == 'setosa')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'labels' is not defined
>>> is_setosa = data(labels == 'setosa')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'labels' is not defined
을 시도 오타는 무엇입니까 이제해야 하나? 데이터 객체를 검사하려면 어떻게해야합니까?
>>> data.labels
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/milenko/miniconda2/lib/python2.7/site-packages/sklearn/datasets/base.py", line 58, in __getattr__
raise AttributeError(key)
AttributeError: labels
>>> data.dtypes
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/milenko/miniconda2/lib/python2.7/site-packages/sklearn/datasets/base.py", line 58, in __getattr__
raise AttributeError(key)
AttributeError: dtypes
이 설명
- class:\n - Iris-Setosa\n - Iris-Versicolour\n - Iris-Virginica\n :
'labels'변수가 정의되어 있지 않습니다. – luoluo
data [ 'labels'] 또는 data.labels ... 데이터 객체를 검사 할 가능성이 있습니다. – FLab
'is_setosa' 변수에 부울 값이 없습니다. 이를 위해'labels == 'setosa'를 비교하고 있습니다. 이제'labels'은 정의되지 않았습니다. 위의 선언을'label = ""'과 같이 쓰고 싶습니까? – ishaan