0

我在使用 Apple Turi Create 和图像分类器时遇到问题。我已经成功创建了一个包含 22 个类别的模型。我最近又添加了 5 个类别,控制台给了我错误警告

Please use dropna() to drop rows with missing target values.

完整的控制台日志如下所示:

[16:30:30] src/nnvm/legacy_json_util.cc:190: Loading symbol saved by previous version v0.8.0. Attempting to upgrade...
[16:30:30] src/nnvm/legacy_json_util.cc:198: Symbol successfully upgraded!
Resizing images...
Performing feature extraction on resized images...
Premature end of JPEG file
Completed  512/1883
Completed 1024/1883
Completed 1536/1883
Completed 1883/1883
PROGRESS: Creating a validation set from 5 percent of training data. This may take a while.
      You can set ``validation_set=None`` to disable validation tracking.

[ERROR] turicreate.toolkits._main: Toolkit error: Target column has missing value.                    
Please use dropna() to drop rows with missing target values.
Traceback (most recent call last):
File "train.py", line 8, in <module>
model = tc.image_classifier.create(train_data, target='label', max_iterations=1000)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/turicreate/toolkits/image_classifier/image_classifier.py", line 132, in create
verbose=verbose)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/turicreate/toolkits/classifier/logistic_classifier.py", line 312, in create
seed=seed)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/turicreate/toolkits/_supervised_learning.py", line 397, in create
options, verbose)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/turicreate/toolkits/_main.py", line 75, in run
raise ToolkitError(str(message))
turicreate.toolkits._main.ToolkitError: Target column has missing value.                    

Please use dropna() to drop rows with missing target values.

我已将turicoremltools升级到最新版本,但我不知道应该在代码中的何处实现dropna()。我只找到了这个参考并遵循了代码。

它看起来像这样:

数据.py

import turicreate as tc

image_data = tc.image_analysis.load_images('images', with_path=True)

labels = ['A', 'B', 'C', 'D']

def get_label(path, labels=labels):
  for label in labels:
       if label in path:
           return label

image_data['label'] = image_data['path'].apply(get_label)

#import os
#image_data['label'] = image_data['path'].apply(lambda path:    os.path.dirname(path).split('/')[-1])

image_data.save('boxes.sframe')

image_data.explore()

火车.py

import turicreate as tc

data = tc.SFrame('boxes.sframe')
data.dropna()

train_data, test_data = data.random_split(0.8)

model = tc.image_classifier.create(train_data, target='label',    max_iterations=1000)

predictions = model.classify(test_data)

results = model.evaluate(test_data)

print "Accuracy           : %s" % results['accuracy']
print "Confusion Matrix   : \n%s" % results['confusion_matrix']

model.save('boxes.model')

请问如何删除所有空列和行?max_iterations =1000对错误也有影响吗?

谢谢你的建议

4

1 回答 1

2

data.dropna()没有完成,您需要编写它:data = data.dropna()
请参阅此处的文档https://apple.github.io/turicreate/docs/api/generated/turicreate.SFrame.dropna.html

于 2018-05-21T20:31:41.160 回答