def test_ovr(self): model = OneVsRestClassifier(LogisticRegression()) dump_multiple_classification( model, allow_failure="StrictVersion(onnxruntime.__version__)" " <= StrictVersion('0.2.1')", target_opset=TARGET_OPSET)
def test_extra_trees_classifier(self): model = ExtraTreesClassifier(n_estimators=3) dump_one_class_classification( model, allow_failure="StrictVersion(onnx.__version__)" " < StrictVersion('1.2') or " "StrictVersion(onnxruntime.__version__)" " <= StrictVersion('0.2.1')", ) dump_binary_classification( model, allow_failure=( "StrictVersion(onnx.__version__) < StrictVersion('1.2') or " "StrictVersion(onnxruntime.__version__)" " <= StrictVersion('0.2.1')" ), ) dump_multiple_classification( model, # Operator cast-1 is not implemented in onnxruntime allow_failure=( "StrictVersion(onnx.__version__) < StrictVersion('1.2') or " "StrictVersion(onnxruntime.__version__)" " <= StrictVersion('0.2.1')" ), )
def test_gradient_boosting_classifier_multi(self): model = GradientBoostingClassifier(n_estimators=3) dump_multiple_classification( model, allow_failure="StrictVersion(onnxruntime.__version__)" "<= StrictVersion('%s')" % THRESHOLD, )
def test_ovr_string(self): model = OneVsRestClassifier(LogisticRegression()) dump_multiple_classification(model, verbose=False, label_string=True, suffix="String", target_opset=TARGET_OPSET)
def test_ova_02(self): model = OneVsRestClassifier(LogisticRegression()) dump_multiple_classification( model, first_class=2, suffix="F2", allow_failure= "StrictVersion(onnxruntime.__version__) <= StrictVersion('0.2.1')")
def test_random_forest_classifier(self): model = RandomForestClassifier(n_estimators=3) dump_one_class_classification(model, allow_failure="StrictVersion(onnx.__version__) < StrictVersion('1.2')") dump_binary_classification(model, allow_failure="StrictVersion(onnx.__version__) < StrictVersion('1.2')") dump_multiple_classification(model, allow_failure="StrictVersion(onnx.__version__) < StrictVersion('1.2')")
def test_ova_string(self): model = OneVsRestClassifier(LogisticRegression()) dump_multiple_classification( model, verbose=False, label_string=True, suffix="String", allow_failure= "StrictVersion(onnxruntime.__version__) <= StrictVersion('0.2.1')")
def test_lightgbm_classifier(self): model = LGBMClassifier(n_estimators=3, min_child_samples=1) dump_binary_classification( model, allow_failure="StrictVersion(onnx.__version__) < " "StrictVersion('1.3.0')") dump_multiple_classification( model, allow_failure="StrictVersion(onnx.__version__) < " "StrictVersion('1.3.0')")
def test_voting_soft_multi(self): model = VotingClassifier(voting='soft', flatten_transform=False, estimators=[('lr', LogisticRegression()), ('lr2', LogisticRegression())]) dump_multiple_classification( model, suffix='Soft-OneOffArray', allow_failure= "StrictVersion(onnxruntime.__version__) <= StrictVersion('0.2.1')")
def test_voting_soft_multi(self): model = VotingClassifier( voting="soft", flatten_transform=False, estimators=[ ("lr", LogisticRegression()), ("lr2", LogisticRegression()), ], ) dump_multiple_classification(model, suffix="Soft", target_opset=TARGET_OPSET)
def test_lightgbm_classifier(self): model = LGBMClassifier(n_estimators=3, min_child_samples=1) dump_binary_classification(model, target_opset={ '': TARGET_OPSET, 'ai.onnx.ml': TARGET_OPSET_ML }) dump_multiple_classification(model, target_opset={ '': TARGET_OPSET, 'ai.onnx.ml': TARGET_OPSET_ML })
def test_voting_soft_multi_weighted42(self): model = VotingClassifier(voting='soft', flatten_transform=False, weights=numpy.array([27, 0.3, 0.5, 0.5]), estimators=[('lr', LogisticRegression()), ('lra', LogisticRegression()), ('lrb', LogisticRegression()), ('lr2', LogisticRegression())]) dump_multiple_classification( model, suffix='Weighted42Soft-OneOffArray', allow_failure= "StrictVersion(onnxruntime.__version__) <= StrictVersion('0.2.1')")
def test_voting_hard_multi(self): # predict_proba is not defined when voting is hard. model = VotingClassifier(voting='hard', flatten_transform=False, estimators=[('lr', LogisticRegression()), ('lr2', DecisionTreeClassifier()) ]) dump_multiple_classification( model, suffix='Hard-OneOffArray', comparable_outputs=[0], allow_failure= "StrictVersion(onnxruntime.__version__) <= StrictVersion('0.2.1')")
def test_voting_soft_multi_weighted(self): model = VotingClassifier( voting="soft", flatten_transform=False, weights=numpy.array([1.8, 0.2]), estimators=[ ("lr", LogisticRegression()), ("lr2", LogisticRegression()), ], ) dump_multiple_classification(model, suffix="WeightedSoft", target_opset=TARGET_OPSET)
def test_xgb_classifier_multi(self): iris = load_iris() X = iris.data[:, :2] y = iris.target xgb = XGBClassifier() xgb.fit(X, y) conv_model = convert_sklearn( xgb, initial_types=[ ('input', FloatTensorType(shape=[None, X.shape[1]]))]) self.assertTrue(conv_model is not None) dump_multiple_classification( xgb, allow_failure="StrictVersion(onnx.__version__) " "< StrictVersion('1.3.0')")
def test_voting_hard_multi(self): # predict_proba is not defined when voting is hard. model = VotingClassifier( voting="hard", flatten_transform=False, estimators=[ ("lr", LogisticRegression()), ("lr2", DecisionTreeClassifier()), ], ) dump_multiple_classification(model, suffix="Hard", comparable_outputs=[0], target_opset=TARGET_OPSET)
def test_decision_tree_classifier(self): model = DecisionTreeClassifier() dump_one_class_classification( model, # Operator cast-1 is not implemented in onnxruntime allow_failure= "StrictVersion(onnx.__version__) < StrictVersion('1.2')") dump_binary_classification( model, allow_failure= "StrictVersion(onnx.__version__) < StrictVersion('1.2')") dump_multiple_classification( model, allow_failure= "StrictVersion(onnx.__version__) < StrictVersion('1.2')")
def test_voting_soft_multi(self): model = VotingClassifier( voting="soft", flatten_transform=False, estimators=[ ("lr", LogisticRegression()), ("lr2", LogisticRegression()), ], ) dump_multiple_classification( model, suffix="Soft-OneOffArray", allow_failure="StrictVersion(onnxruntime.__version__)" " <= StrictVersion('0.2.1')", )
def test_voting_soft_multi_weighted(self): model = VotingClassifier( voting="soft", flatten_transform=False, weights=numpy.array([1.8, 0.2]), estimators=[ ("lr", LogisticRegression()), ("lr2", LogisticRegression()), ], ) dump_multiple_classification( model, suffix="WeightedSoft", allow_failure="StrictVersion(onnxruntime.__version__)" " <= StrictVersion('0.2.1')", )
def test_xgb_classifier_multi_reglog(self): iris = load_iris() X = iris.data[:, :2] y = iris.target xgb = XGBClassifier(objective='reg:logistic') xgb.fit(X, y) conv_model = convert_sklearn( xgb, initial_types=[ ('input', FloatTensorType(shape=[None, X.shape[1]]))], target_opset=TARGET_OPSET) self.assertTrue(conv_model is not None) dump_multiple_classification( xgb, suffix="RegLog", allow_failure="StrictVersion(onnx.__version__) < " "StrictVersion('1.3.0')")
def test_voting_soft_multi_string(self): model = VotingClassifier( voting="soft", flatten_transform=False, estimators=[ ("lr", LogisticRegression()), ("lr2", LogisticRegression()), ], ) dump_multiple_classification( model, label_string=True, suffix="Soft", allow_failure="StrictVersion(onnxruntime.__version__)" " <= StrictVersion('0.2.1')", target_opset=TARGET_OPSET)
def test_voting_hard_multi(self): # predict_proba is not defined when voting is hard. model = VotingClassifier( voting="hard", flatten_transform=False, estimators=[ ("lr", LogisticRegression()), ("lr2", DecisionTreeClassifier()), ], ) dump_multiple_classification( model, suffix="Hard", comparable_outputs=[0], allow_failure="StrictVersion(onnxruntime.__version__)" " <= StrictVersion('0.5.0')", )
def test_voting_hard_multi_weighted(self): # predict_proba is not defined when voting is hard. model = VotingClassifier( voting="hard", flatten_transform=False, weights=numpy.array([1000, 1]), estimators=[ ("lr", LogisticRegression()), ("lr2", DecisionTreeClassifier()), ], ) dump_multiple_classification( model, suffix="WeightedHard", comparable_outputs=[0], allow_failure="StrictVersion(onnxruntime.__version__)" " <= StrictVersion('0.5.0')", target_opset=TARGET_OPSET)
def test_voting_soft_multi_weighted42(self): model = VotingClassifier( voting="soft", flatten_transform=False, weights=numpy.array([27, 0.3, 0.5, 0.5]), estimators=[ ("lr", LogisticRegression()), ("lra", LogisticRegression()), ("lrb", LogisticRegression()), ("lr2", LogisticRegression()), ], ) dump_multiple_classification( model, suffix="Weighted42Soft", allow_failure="StrictVersion(onnxruntime.__version__)" " <= StrictVersion('0.2.1')", target_opset=TARGET_OPSET)
def test_xgb_classifier_multi(self): iris = load_iris() X = iris.data[:, :2] y = iris.target xgb = XGBClassifier() xgb.fit(X, y) conv_model = convert_sklearn( xgb, initial_types=[('input', FloatTensorType(shape=[None, X.shape[1]])) ], target_opset={ '': TARGET_OPSET, 'ai.onnx.ml': TARGET_OPSET_ML }) self.assertTrue(conv_model is not None) dump_multiple_classification(xgb, target_opset={ '': TARGET_OPSET, 'ai.onnx.ml': TARGET_OPSET_ML })
def test_decision_tree_classifier(self): model = DecisionTreeClassifier() dump_one_class_classification(model) dump_binary_classification(model) dump_multiple_classification(model) dump_multiple_classification(model, label_uint8=True) dump_multiple_classification(model, label_string=True)
def test_decision_tree_classifier(self): model = DecisionTreeClassifier() dump_one_class_classification( model, # Operator cast-1 is not implemented in onnxruntime allow_failure="StrictVersion(onnx.__version__)" " < StrictVersion('1.3') or " "StrictVersion(onnxruntime.__version__)" " <= StrictVersion('0.2.1')", ) dump_binary_classification( model, allow_failure="StrictVersion(onnx.__version__)" " < StrictVersion('1.3') or " "StrictVersion(onnxruntime.__version__)" " <= StrictVersion('0.2.1')", ) dump_multiple_classification( model, allow_failure="StrictVersion(onnx.__version__)" " < StrictVersion('1.3') or " "StrictVersion(onnxruntime.__version__)" " <= 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')")
def test_random_forest_classifier(self): model = RandomForestClassifier(n_estimators=3) dump_one_class_classification(model) dump_binary_classification(model) dump_multiple_classification(model)
def test_ovr(self): model = OneVsRestClassifier(LogisticRegression()) dump_multiple_classification(model, target_opset=TARGET_OPSET)
def test_ovr_02(self): model = OneVsRestClassifier(LogisticRegression()) dump_multiple_classification(model, first_class=2, suffix="F2", target_opset=TARGET_OPSET)