Repository: onnx/sklearn-onnx

Issue:
AttributeError: 'numpy.uint8' object has no attribute 'encode'
Hi Team,

I got such error when trying to convert ExtraTreesClassifier. This classifier was trained by another person in internet and I downloaded it as a pkl format, loaded using joblib. 
Please advise. Thank you.

![image](https://user-images.githubusercontent.com/7789546/83967196-8b87ca80-a8e9-11ea-9b42-2d4a83cda27d.png)



Discussion:

Resolving patch:
diff --git a/skl2onnx/_parse.py b/skl2onnx/_parse.py
--- a/skl2onnx/_parse.py
+++ b/skl2onnx/_parse.py
@@ -353,6 +353,8 @@ def _parse_sklearn_classifier(scope, model, inputs, custom_parsers=None):
         this_operator.classlabels_int64s = classes
     elif np.issubdtype(classes.dtype, np.signedinteger):
         this_operator.classlabels_int64s = classes
+    elif np.issubdtype(classes.dtype, np.unsignedinteger):
+        this_operator.classlabels_int64s = classes
     else:
         classes = np.array([s.encode('utf-8') for s in classes])
         this_operator.classlabels_strings = classes


Test patch:
diff --git a/tests/test_sklearn_decision_tree_converters.py b/tests/test_sklearn_decision_tree_converters.py
--- a/tests/test_sklearn_decision_tree_converters.py
+++ b/tests/test_sklearn_decision_tree_converters.py
@@ -94,8 +94,21 @@ def test_decision_tree_classifier(self):
             allow_failure="StrictVersion(onnx.__version__)"
                           " < StrictVersion('1.3') or "
                           "StrictVersion(onnxruntime.__version__)"
-                          " <= StrictVersion('0.2.1')",
-        )
+                          " <= StrictVersion('0.2.1')")
+        dump_multiple_classification(
+            model,
+            label_uint8=True,
+            allow_failure="StrictVersion(onnx.__version__)"
+                          " < StrictVersion('1.3') or "
+                          "StrictVersion(onnxruntime.__version__)"
+                          " <= StrictVersion('0.2.1')")
+        dump_multiple_classification(
+            model,
+            label_string=True,
+            allow_failure="StrictVersion(onnx.__version__)"
+                          " < StrictVersion('1.3') or "
+                          "StrictVersion(onnxruntime.__version__)"
+                          " <= StrictVersion('0.2.1')")
 
     @unittest.skipIf(not onnx_built_with_ml(),
                      reason="Requires ONNX-ML extension.")
diff --git a/tests/test_utils/tests_helper.py b/tests/test_utils/tests_helper.py
--- a/tests/test_utils/tests_helper.py
+++ b/tests/test_utils/tests_helper.py
@@ -533,6 +533,7 @@ def dump_multiple_classification(
         allow_failure=None,
         verbose=False,
         label_string=False,
+        label_uint8=False,
         first_class=0,
         comparable_outputs=None,
         target_opset=None):
@@ -549,7 +550,14 @@ def dump_multiple_classification(
     y = [0, 1, 2, 1, 1, 2]
     y = [i + first_class for i in y]
     if label_string:
+        if label_uint8:
+            raise AssertionError(
+                "label_string and label_uint8 cannot be both True")
         y = ["l%d" % i for i in y]
+        suffix += 'String'
+    elif label_uint8:
+        y = numpy.array(y).astype(numpy.uint8)
+        suffix += 'Uint8'
     model.fit(X, y)
     if verbose:
         print("[dump_multiple_classification] model '{}'".format(