def test_multiple_transform(self): x = pandas.DataFrame(data=[[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]]) x.columns = "X1 X2".split() content = self.get_onnx_mul() res = list(OnnxTransformer.enumerate_create(content)) self.assertNotEmpty(res) for _, tr in res: tr.fit() self.assertRaise(lambda tr=tr: tr.transform(x), RuntimeError)
def test_pipeline_iris(self): iris = load_iris() X, y = iris.data, iris.target pipe = make_pipeline(PCA(n_components=2), LogisticRegression()) pipe.fit(X, y) onx = convert_sklearn(pipe, initial_types=[ ('input', FloatTensorType((None, X.shape[1])))]) onx_bytes = onx.SerializeToString() res = list(OnnxTransformer.enumerate_create(onx_bytes)) outputs = [] shapes = [] for k, tr in res: outputs.append(k) tr.fit() y = tr.transform(X) self.assertEqual(y.shape[0], X.shape[0]) shapes.append(y.shape) self.assertEqual(len(set(outputs)), len(outputs)) shapes = set(shapes) self.assertEqual(shapes, {(150, 3), (150, 4), (150, 2), (150,)})