将sklearn模型转换为coreml时,CoreMLTools中的ValueError

时间:2018-08-28 11:21:20

标签: python scikit-learn coreml

coremltools sklearn转换器,同时转换它提供的逻辑回归模型

  

ValueError:类标签必须全部为int类型或所有字符串类型。

这是coremltools部分中的代码

coreml_model = coremltools.converters.sklearn.convert(clf_rgb,
    ["h","Cr","Cb","A","U","V","B"],"skin")

完成堆栈跟踪

--------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-80-2ea49666c38c> in <module>()
----> 1 coreml_model = coremltools.converters.sklearn.convert(clf_rgb,["h","Cr","Cb","A","U","V","B"],"skin")

/usr/local/lib/python3.6/site-packages/coremltools/converters/sklearn/_converter.py in convert(sk_obj, input_features, output_feature_names)
    144     from ._converter_internal import _convert_sklearn_model
    145     spec = _convert_sklearn_model(
--> 146             sk_obj, input_features, output_feature_names, class_labels = None)
    147 
    148     return MLModel(spec)

/usr/local/lib/python3.6/site-packages/coremltools/converters/sklearn/_converter_internal.py in _convert_sklearn_model(input_sk_obj, input_features, output_feature_names, class_labels)
    270 
    271         output_features = _fm.process_or_validate_classifier_output_features(
--> 272                 output_feature_names, class_labels, supports_output_scores)
    273 
    274     elif overall_mode == "regressor":

/usr/local/lib/python3.6/site-packages/coremltools/models/_feature_management.py in process_or_validate_classifier_output_features(output_features, class_labels, supports_class_scores)
     42 
     43     else:
---> 44         raise ValueError('Class labels must be all of type int or all of type string.')
     45 
     46     if output_features is None:

ValueError: Class labels must be all of type int or all of type string.

0 个答案:

没有答案