hummingbird/tests/test_sklearn_decision_tree_...

834 строки
37 KiB
Python
Исходник Постоянная ссылка Обычный вид История

First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
"""
Tests Sklearn RandomForest, DecisionTree, ExtraTrees converters.
"""
import unittest
import warnings
import sys
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
import numpy as np
from sklearn.ensemble import ExtraTreesClassifier, ExtraTreesRegressor, RandomForestClassifier, RandomForestRegressor
from sklearn.tree import DecisionTreeClassifier, DecisionTreeRegressor
from sklearn import datasets
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
2020-05-06 02:34:12 +03:00
import hummingbird.ml
from hummingbird.ml.exceptions import MissingConverter
from hummingbird.ml._utils import tvm_installed, is_on_github_actions
from hummingbird.ml import constants
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
from tree_utils import dt_implementation_map
import random
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
class TestSklearnTreeConverter(unittest.TestCase):
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
# Check tree implementation
def test_random_forest_implementation(self):
warnings.filterwarnings("ignore")
np.random.seed(0)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
X = np.random.rand(1, 1)
X = np.array(X, dtype=np.float32)
y = np.random.randint(2, size=1)
for model in [RandomForestClassifier(n_estimators=1, max_depth=1), RandomForestRegressor(n_estimators=1, max_depth=1)]:
for extra_config_param in ["tree_trav", "perf_tree_trav", "gemm"]:
model.fit(X, y)
torch_model = hummingbird.ml.convert(
model, "torch", extra_config={constants.TREE_IMPLEMENTATION: extra_config_param}
)
self.assertIsNotNone(torch_model)
2021-01-12 20:47:28 +03:00
self.assertTrue(str(type(list(torch_model.model._operators)[0])) == dt_implementation_map[extra_config_param])
2020-05-01 20:01:51 +03:00
# Used for classification tests
def _run_tree_classification_converter(
self, model_type, num_classes, backend="torch", extra_config={}, labels_shift=0, **kwargs
):
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
warnings.filterwarnings("ignore")
for max_depth in [1, 3, 8, 10, 12, None]:
np.random.seed(0)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
X = np.random.rand(100, 200)
X = np.array(X, dtype=np.float32)
y = np.random.randint(num_classes, size=100) + labels_shift
model = model_type(max_depth=max_depth, **kwargs)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
model.fit(X, y)
torch_model = hummingbird.ml.convert(model, backend, X, extra_config=extra_config)
self.assertIsNotNone(torch_model)
np.testing.assert_allclose(model.predict_proba(X), torch_model.predict_proba(X), rtol=1e-06, atol=1e-06)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
np.testing.assert_allclose(model.predict(X), torch_model.predict(X), rtol=1e-06, atol=1e-06)
# Random forest binary classifier
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
def test_random_forest_classifier_binary_converter(self):
self._run_tree_classification_converter(RandomForestClassifier, 2, n_estimators=10)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
# Random forest gemm classifier
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
def test_random_forest_gemm_classifier_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier, 2, extra_config={constants.TREE_IMPLEMENTATION: "gemm"}, n_estimators=10
)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
# Random forest tree_trav classifier
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
def test_random_forest_tree_trav_classifier_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier, 2, extra_config={constants.TREE_IMPLEMENTATION: "tree_trav"}, n_estimators=10
)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
# Random forest perf_tree_trav classifier
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
def test_random_forest_perf_tree_trav_classifier_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier, 2, extra_config={constants.TREE_IMPLEMENTATION: "perf_tree_trav"}, n_estimators=10
)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
# Random forest multi classifier
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
def test_random_forest_multi_classifier_converter(self):
self._run_tree_classification_converter(RandomForestClassifier, 3, n_estimators=10)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
# Random forest gemm multi classifier
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
def test_random_forest_gemm_multi_classifier_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier, 3, extra_config={constants.TREE_IMPLEMENTATION: "gemm"}, n_estimators=10
)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
# Random forest tree_trav multi classifier
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
def test_random_forest_tree_trav_multi_classifier_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier, 3, extra_config={constants.TREE_IMPLEMENTATION: "tree_trav"}, n_estimators=10
)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
# Random forest perf_tree_trav multi classifier
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
def test_random_forest_perf_tree_trav_multi_classifier_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier, 3, extra_config={constants.TREE_IMPLEMENTATION: "perf_tree_trav"}, n_estimators=10
)
# Random forest gemm classifier shifted classes
def test_random_forest_gemm_classifier_shifted_labels_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier, 3, labels_shift=2, extra_config={constants.TREE_IMPLEMENTATION: "gemm"}, n_estimators=10
)
# Random forest tree_trav classifier shifted classes
def test_random_forest_tree_trav_classifier_shifted_labels_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier,
3,
labels_shift=2,
extra_config={constants.TREE_IMPLEMENTATION: "tree_trav"},
n_estimators=10,
)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
# Random forest perf_tree_trav classifier shifted classes
def test_random_forest_perf_tree_trav_classifier_shifted_labels_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier,
3,
labels_shift=2,
extra_config={constants.TREE_IMPLEMENTATION: "perf_tree_trav"},
n_estimators=10,
)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
# Used for regression tests
def _run_tree_regressor_converter(self, model_type, num_classes, backend="torch", extra_config={}, **kwargs):
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
warnings.filterwarnings("ignore")
for max_depth in [1, 3, 8, 10, 12, None]:
model = model_type(max_depth=max_depth, **kwargs)
np.random.seed(0)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
X = np.random.rand(100, 200)
X = np.array(X, dtype=np.float32)
y = np.random.randint(num_classes, size=100)
model.fit(X, y)
torch_model = hummingbird.ml.convert(model, backend, X, extra_config=extra_config)
self.assertIsNotNone(torch_model)
np.testing.assert_allclose(model.predict(X), torch_model.predict(X), rtol=1e-06, atol=1e-06)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
# Random forest regressor
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
def test_random_forest_regressor_converter(self):
self._run_tree_regressor_converter(RandomForestRegressor, 1000, n_estimators=10)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
# Random forest gemm regressor
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
def test_random_forest_gemm_regressor_converter(self):
self._run_tree_regressor_converter(
RandomForestRegressor, 1000, extra_config={constants.TREE_IMPLEMENTATION: "gemm"}, n_estimators=10
)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
# Random forest tree_trav regressor
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
def test_random_forest_tree_trav_regressor_converter(self):
self._run_tree_regressor_converter(
RandomForestRegressor, 1000, extra_config={constants.TREE_IMPLEMENTATION: "tree_trav"}, n_estimators=10
)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
# Random forest perf_tree_trav regressor
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
def test_random_forest_perf_tree_trav_regressor_converter(self):
self._run_tree_regressor_converter(
RandomForestRegressor, 1000, extra_config={constants.TREE_IMPLEMENTATION: "perf_tree_trav"}, n_estimators=10
)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
# Extra trees regressor
def test_extra_trees_regressor_converter(self):
self._run_tree_regressor_converter(ExtraTreesRegressor, 1000, n_estimators=10)
# Extra trees gemm regressor
def test_extra_trees_gemm_regressor_converter(self):
self._run_tree_regressor_converter(
ExtraTreesRegressor, 1000, extra_config={constants.TREE_IMPLEMENTATION: "gemm"}, n_estimators=10
)
# Extra trees tree_trav regressor
def test_extra_trees_tree_trav_regressor_converter(self):
self._run_tree_regressor_converter(
ExtraTreesRegressor, 1000, extra_config={constants.TREE_IMPLEMENTATION: "tree_trav"}, n_estimators=10
)
# Extra trees perf_tree_trav regressor
def test_extra_trees_perf_tree_trav_regressor_converter(self):
self._run_tree_regressor_converter(
ExtraTreesRegressor, 1000, extra_config={constants.TREE_IMPLEMENTATION: "perf_tree_trav"}, n_estimators=10
)
# Decision tree regressor
def test_decision_tree_regressor_converter(self):
self._run_tree_regressor_converter(DecisionTreeRegressor, 1000)
# Decision tree gemm regressor
def test_decision_tree_gemm_regressor_converter(self):
self._run_tree_regressor_converter(DecisionTreeRegressor, 1000, extra_config={constants.TREE_IMPLEMENTATION: "gemm"})
# Decision tree tree_trav regressor
def test_decision_tree_tree_trav_regressor_converter(self):
self._run_tree_regressor_converter(
DecisionTreeRegressor, 1000, extra_config={constants.TREE_IMPLEMENTATION: "tree_trav"}
)
# Decision tree perf_tree_trav regressor
def test_decision_tree_perf_tree_trav_regressor_converter(self):
self._run_tree_regressor_converter(
DecisionTreeRegressor, 1000, extra_config={constants.TREE_IMPLEMENTATION: "perf_tree_trav"}
)
# Decision tree classifier
def test_decision_tree_classifier_converter(self):
self._run_tree_classification_converter(DecisionTreeClassifier, 3)
# Extra trees classifier
def test_extra_trees_classifier_converter(self):
self._run_tree_classification_converter(ExtraTreesClassifier, 3, n_estimators=10)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
# Used for small tree tests
def _run_random_forest_classifier_single_node_tree_converter(self, extra_config={}):
warnings.filterwarnings("ignore")
np.random.seed(0)
X = np.random.rand(1, 1)
X = np.array(X, dtype=np.float32)
y = np.random.randint(1, size=1)
model = RandomForestClassifier(n_estimators=1).fit(X, y)
torch_model = hummingbird.ml.convert(model, "torch", extra_config=extra_config)
self.assertIsNotNone(torch_model)
np.testing.assert_allclose(model.predict_proba(X), torch_model.predict_proba(X), rtol=1e-06, atol=1e-06)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
# Small tree gemm implementation
def test_random_forest_gemm_classifier_single_node_tree_converter(self):
self._run_random_forest_classifier_single_node_tree_converter(extra_config={constants.TREE_IMPLEMENTATION: "gemm"})
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
# Small tree tree_trav implementation
def test_random_forest_tree_trav_classifier_single_node_tree_converter(self):
self._run_random_forest_classifier_single_node_tree_converter(
extra_config={constants.TREE_IMPLEMENTATION: "tree_trav"}
)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
# Small tree perf_tree_trav implementation
def test_random_forest_perf_tree_trav_classifier_single_node_tree_converter(self):
self._run_random_forest_classifier_single_node_tree_converter(
extra_config={constants.TREE_IMPLEMENTATION: "perf_tree_trav"}
)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
# Another small tree tests
def test_random_forest_classifier_small_tree_converter(self):
seed = 0
np.random.seed(seed=0)
N = 9
X = np.random.randn(N, 8)
y = np.random.randint(low=0, high=2, size=N)
model = RandomForestClassifier(random_state=seed)
model.fit(X, y)
torch_model = hummingbird.ml.convert(model, "torch")
self.assertIsNotNone(torch_model)
np.testing.assert_allclose(model.predict_proba(X), torch_model.predict_proba(X), rtol=1e-06, atol=1e-06)
# Float 64 classification test helper
def _run_float64_tree_classification_converter(self, model_type, num_classes, extra_config={}, labels_shift=0, **kwargs):
warnings.filterwarnings("ignore")
for max_depth in [1, 3, 8, 10, 12, None]:
np.random.seed(0)
X = np.random.rand(100, 200)
y = np.random.randint(num_classes, size=100) + labels_shift
model = model_type(max_depth=max_depth, **kwargs)
model.fit(X, y)
torch_model = hummingbird.ml.convert(model, "torch", extra_config=extra_config)
self.assertIsNotNone(torch_model)
np.testing.assert_allclose(model.predict_proba(X), torch_model.predict_proba(X), rtol=1e-06, atol=1e-06)
# Random forest binary classifier (float64 data)
def test_float64_random_forest_classifier_binary_converter(self):
self._run_float64_tree_classification_converter(RandomForestClassifier, 2, n_estimators=10)
# Decision tree classifier (float64 data)
def test_float64_decision_tree_classifier_converter(self):
self._run_float64_tree_classification_converter(DecisionTreeClassifier, 3)
# Extra trees classifier (float64 data)
def test_float64_extra_trees_classifier_converter(self):
self._run_float64_tree_classification_converter(ExtraTreesClassifier, 3, n_estimators=10)
# Float 64 regression tests helper
def _run_float64_tree_regressor_converter(self, model_type, num_classes, extra_config={}, **kwargs):
warnings.filterwarnings("ignore")
for max_depth in [1, 3, 8, 10, 12, None]:
model = model_type(max_depth=max_depth, **kwargs)
np.random.seed(0)
X = np.random.rand(100, 200)
y = np.random.randint(num_classes, size=100)
model.fit(X, y)
torch_model = hummingbird.ml.convert(model, "torch", extra_config=extra_config)
self.assertIsNotNone(torch_model)
np.testing.assert_allclose(model.predict(X), torch_model.predict(X), rtol=1e-06, atol=1e-06)
# Random forest regressor (float64 data)
def test_float64_random_forest_regressor_converter(self):
self._run_float64_tree_regressor_converter(RandomForestRegressor, 1000, n_estimators=10)
# Decision tree regressor (float64 data)
def test_float64_decision_tree_regressor_converter(self):
self._run_float64_tree_regressor_converter(DecisionTreeRegressor, 1000)
# Extra trees regressor (float64 data)
def test_float64_extra_trees_regressor_converter(self):
self._run_float64_tree_regressor_converter(ExtraTreesRegressor, 1000, n_estimators=10)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
# Failure Cases
def test_random_forest_classifier_raises_wrong_type(self):
warnings.filterwarnings("ignore")
np.random.seed(0)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
X = np.random.rand(100, 200)
X = np.array(X, dtype=np.float32)
y = np.random.randint(3, size=100).astype(np.float32) # y must be int, not float, should error
model = RandomForestClassifier(n_estimators=10).fit(X, y)
self.assertRaises(RuntimeError, hummingbird.ml.convert, model, "torch")
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
def test_random_forest_classifier_raises_wrong_extra_config(self):
warnings.filterwarnings("ignore")
np.random.seed(0)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
X = np.array(np.random.rand(100, 200), dtype=np.float32)
y = np.random.randint(3, size=100)
model = RandomForestClassifier(n_estimators=10).fit(X, y)
self.assertRaises(
MissingConverter, hummingbird.ml.convert, model, "torch", extra_config={constants.TREE_IMPLEMENTATION: "nonsense"}
)
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
# Test trees with TorchScript backend
# Random forest binary classifier
def test_random_forest_ts_classifier_binary_converter(self):
self._run_tree_classification_converter(RandomForestClassifier, 2, "torch.jit", n_estimators=10)
# Random forest gemm classifier
def test_random_forest_ts_gemm_classifier_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier, 2, "torch.jit", extra_config={constants.TREE_IMPLEMENTATION: "gemm"}, n_estimators=10
)
# Random forest tree_trav classifier
def test_random_forest_ts_tree_trav_classifier_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier, 2, "torch.jit", extra_config={constants.TREE_IMPLEMENTATION: "tree_trav"}, n_estimators=10
)
# Random forest perf_tree_trav classifier
def test_random_forest_ts_perf_tree_trav_classifier_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier,
2,
"torch.jit",
extra_config={constants.TREE_IMPLEMENTATION: "perf_tree_trav"},
n_estimators=10,
)
# Random forest multi classifier
def test_random_forest_ts_multi_classifier_converter(self):
self._run_tree_classification_converter(RandomForestClassifier, 3, "torch.jit", n_estimators=10)
# Random forest gemm multi classifier
def test_random_forest_ts_gemm_multi_classifier_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier, 3, "torch.jit", extra_config={constants.TREE_IMPLEMENTATION: "gemm"}, n_estimators=10
)
# Random forest tree_trav multi classifier
def test_random_forest_ts_tree_trav_multi_classifier_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier, 3, "torch.jit", extra_config={constants.TREE_IMPLEMENTATION: "tree_trav"}, n_estimators=10
)
# Random forest perf_tree_trav multi classifier
def test_random_forest_ts_perf_tree_trav_multi_classifier_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier,
3,
"torch.jit",
extra_config={constants.TREE_IMPLEMENTATION: "perf_tree_trav"},
n_estimators=10,
)
# Random forest gemm classifier shifted classes
def test_random_forest_ts_gemm_classifier_shifted_labels_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier,
3,
"torch.jit",
labels_shift=2,
extra_config={constants.TREE_IMPLEMENTATION: "gemm"},
n_estimators=10,
)
# Random forest tree_trav classifier shifted classes
def test_random_forest_ts_tree_trav_classifier_shifted_labels_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier,
3,
"torch.jit",
labels_shift=2,
extra_config={constants.TREE_IMPLEMENTATION: "tree_trav"},
n_estimators=10,
)
# Random forest perf_tree_trav classifier shifted classes
def test_random_forest_ts_perf_tree_trav_classifier_shifted_labels_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier,
3,
"torch.jit",
labels_shift=2,
extra_config={constants.TREE_IMPLEMENTATION: "perf_tree_trav"},
n_estimators=10,
)
# Random forest regressor
def test_random_forest_ts_regressor_converter(self):
self._run_tree_regressor_converter(RandomForestRegressor, 1000, "torch.jit", n_estimators=10)
# Random forest gemm regressor
def test_random_forest_ts_gemm_regressor_converter(self):
self._run_tree_regressor_converter(
RandomForestRegressor, 1000, "torch.jit", extra_config={constants.TREE_IMPLEMENTATION: "gemm"}, n_estimators=10
)
# Random forest tree_trav regressor
def test_random_forest_ts_tree_trav_regressor_converter(self):
self._run_tree_regressor_converter(
RandomForestRegressor,
1000,
"torch.jit",
extra_config={constants.TREE_IMPLEMENTATION: "tree_trav"},
n_estimators=10,
)
# Random forest perf_tree_trav regressor
def test_random_forest_ts_perf_tree_trav_regressor_converter(self):
self._run_tree_regressor_converter(
RandomForestRegressor,
1000,
"torch.jit",
extra_config={constants.TREE_IMPLEMENTATION: "perf_tree_trav"},
n_estimators=10,
)
# Extra trees regressor
def test_extra_trees_ts_regressor_converter(self):
self._run_tree_regressor_converter(ExtraTreesRegressor, 1000, "torch.jit", n_estimators=10)
# Extra trees gemm regressor
def test_extra_trees_ts_gemm_regressor_converter(self):
self._run_tree_regressor_converter(
ExtraTreesRegressor, 1000, "torch.jit", extra_config={constants.TREE_IMPLEMENTATION: "gemm"}, n_estimators=10
)
# Extra trees tree_trav regressor
def test_extra_trees_ts_tree_trav_regressor_converter(self):
self._run_tree_regressor_converter(
ExtraTreesRegressor, 1000, "torch.jit", extra_config={constants.TREE_IMPLEMENTATION: "tree_trav"}, n_estimators=10
)
# Extra trees perf_tree_trav regressor
def test_extra_trees_ts_perf_tree_trav_regressor_converter(self):
self._run_tree_regressor_converter(
ExtraTreesRegressor,
1000,
"torch.jit",
extra_config={constants.TREE_IMPLEMENTATION: "perf_tree_trav"},
n_estimators=10,
)
# Decision tree regressor
def test_decision_tree_ts_regressor_converter(self):
self._run_tree_regressor_converter(DecisionTreeRegressor, 1000, "torch.jit")
# Decision tree gemm regressor
def test_decision_tree_ts_gemm_regressor_converter(self):
self._run_tree_regressor_converter(
DecisionTreeRegressor, 1000, "torch.jit", extra_config={constants.TREE_IMPLEMENTATION: "gemm"}
)
# Decision tree tree_trav regressor
def test_decision_tree_ts_tree_trav_regressor_converter(self):
self._run_tree_regressor_converter(
DecisionTreeRegressor, 1000, "torch.jit", extra_config={constants.TREE_IMPLEMENTATION: "tree_trav"}
)
# Decision tree perf_tree_trav regressor
def test_decision_tree_ts_perf_tree_trav_regressor_converter(self):
self._run_tree_regressor_converter(
DecisionTreeRegressor, 1000, "torch.jit", extra_config={constants.TREE_IMPLEMENTATION: "perf_tree_trav"}
)
# Decision tree classifier
def test_decision_tree_ts_classifier_converter(self):
self._run_tree_classification_converter(
DecisionTreeClassifier, 3, "torch.jit",
)
# Extra trees classifier
def test_extra_trees_ts_classifier_converter(self):
self._run_tree_classification_converter(ExtraTreesClassifier, 3, "torch.jit", n_estimators=10)
# Test trees with TVM backend
# Random forest gemm classifier
@unittest.skipIf(not (tvm_installed()), reason="TVM tests require TVM")
@unittest.skipIf(
((sys.platform == "linux") and is_on_github_actions()),
reason="This test is flaky on Ubuntu on GitHub Actions. See https://github.com/microsoft/hummingbird/pull/709 for more info.",
)
def test_random_forest_tvm_gemm_classifier_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier,
2,
"tvm",
extra_config={constants.TREE_IMPLEMENTATION: "gemm", constants.TVM_MAX_FUSE_DEPTH: 30},
n_estimators=10,
)
# Random forest tree_trav classifier
@unittest.skipIf(not (tvm_installed()), reason="TVM tests require TVM")
@unittest.skipIf(
((sys.platform == "linux") and is_on_github_actions()),
reason="This test is flaky on Ubuntu on GitHub Actions. See https://github.com/microsoft/hummingbird/pull/709 for more info.",
)
def test_random_forest_tvm_tree_trav_classifier_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier,
2,
"tvm",
extra_config={constants.TREE_IMPLEMENTATION: "tree_trav", constants.TVM_MAX_FUSE_DEPTH: 30},
n_estimators=10,
)
# Random forest perf_tree_trav classifier
@unittest.skipIf(not (tvm_installed()), reason="TVM tests require TVM")
@unittest.skipIf(
((sys.platform == "linux") and is_on_github_actions()),
reason="This test is flaky on Ubuntu on GitHub Actions. See https://github.com/microsoft/hummingbird/pull/709 for more info.",
)
def test_random_forest_tvm_perf_tree_trav_classifier_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier,
2,
"tvm",
extra_config={constants.TREE_IMPLEMENTATION: "perf_tree_trav", constants.TVM_MAX_FUSE_DEPTH: 30},
n_estimators=10,
)
# Random forest gemm multi classifier
@unittest.skipIf(not (tvm_installed()), reason="TVM tests require TVM")
@unittest.skipIf(
((sys.platform == "linux") and is_on_github_actions()),
reason="This test is flaky on Ubuntu on GitHub Actions. See https://github.com/microsoft/hummingbird/pull/709 for more info.",
)
def test_random_forest_tvm_gemm_multi_classifier_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier,
3,
"tvm",
extra_config={constants.TREE_IMPLEMENTATION: "gemm", constants.TVM_MAX_FUSE_DEPTH: 30},
n_estimators=10,
)
# Random forest tree_trav multi classifier
@unittest.skipIf(not (tvm_installed()), reason="TVM tests require TVM")
@unittest.skipIf(
((sys.platform == "linux") and is_on_github_actions()),
reason="This test is flaky on Ubuntu on GitHub Actions. See https://github.com/microsoft/hummingbird/pull/709 for more info.",
)
def test_random_forest_tvm_tree_trav_multi_classifier_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier,
3,
"tvm",
extra_config={constants.TREE_IMPLEMENTATION: "tree_trav", constants.TVM_MAX_FUSE_DEPTH: 30},
n_estimators=10,
)
# Random forest perf_tree_trav multi classifier
@unittest.skipIf(not (tvm_installed()), reason="TVM tests require TVM")
@unittest.skipIf(
((sys.platform == "linux") and is_on_github_actions()),
reason="This test is flaky on Ubuntu on GitHub Actions. See https://github.com/microsoft/hummingbird/pull/709 for more info.",
)
def test_random_forest_tvm_perf_tree_trav_multi_classifier_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier,
3,
"tvm",
extra_config={constants.TREE_IMPLEMENTATION: "perf_tree_trav", constants.TVM_MAX_FUSE_DEPTH: 30},
n_estimators=10,
)
# Random forest gemm classifier shifted classes
@unittest.skipIf(not (tvm_installed()), reason="TVM tests require TVM")
@unittest.skipIf(
((sys.platform == "linux") and is_on_github_actions()),
reason="This test is flaky on Ubuntu on GitHub Actions. See https://github.com/microsoft/hummingbird/pull/709 for more info.",
)
def test_random_forest_tvm_gemm_classifier_shifted_labels_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier,
3,
"tvm",
labels_shift=2,
extra_config={constants.TREE_IMPLEMENTATION: "gemm", constants.TVM_MAX_FUSE_DEPTH: 30},
n_estimators=10,
)
# Random forest tree_trav classifier shifted classes
@unittest.skipIf(not (tvm_installed()), reason="TVM tests require TVM")
@unittest.skipIf(
((sys.platform == "linux") and is_on_github_actions()),
reason="This test is flaky on Ubuntu on GitHub Actions. See https://github.com/microsoft/hummingbird/pull/709 for more info.",
)
def test_random_forest_tvm_tree_trav_classifier_shifted_labels_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier,
3,
"tvm",
labels_shift=2,
extra_config={constants.TREE_IMPLEMENTATION: "tree_trav", constants.TVM_MAX_FUSE_DEPTH: 30},
n_estimators=10,
)
# Random forest perf_tree_trav classifier shifted classes
@unittest.skipIf(not (tvm_installed()), reason="TVM tests require TVM")
@unittest.skipIf(
((sys.platform == "linux") and is_on_github_actions()),
reason="This test is flaky on Ubuntu on GitHub Actions. See https://github.com/microsoft/hummingbird/pull/709 for more info.",
)
def test_random_forest_tvm_perf_tree_trav_classifier_shifted_labels_converter(self):
self._run_tree_classification_converter(
RandomForestClassifier,
3,
"tvm",
labels_shift=2,
extra_config={constants.TREE_IMPLEMENTATION: "perf_tree_trav", constants.TVM_MAX_FUSE_DEPTH: 10},
n_estimators=10,
)
# Random forest gemm regressor
@unittest.skipIf(not (tvm_installed()), reason="TVM tests require TVM")
@unittest.skipIf(
((sys.platform == "linux") and is_on_github_actions()),
reason="This test is flaky on Ubuntu on GitHub Actions. See https://github.com/microsoft/hummingbird/pull/709 for more info.",
)
def test_random_forest_tvm_gemm_regressor_converter(self):
self._run_tree_regressor_converter(
RandomForestRegressor,
1000,
"tvm",
extra_config={constants.TREE_IMPLEMENTATION: "gemm", constants.TVM_MAX_FUSE_DEPTH: 30},
n_estimators=10,
)
# Random forest tree_trav regressor
@unittest.skipIf(not (tvm_installed()), reason="TVM tests require TVM")
@unittest.skipIf(
((sys.platform == "linux") and is_on_github_actions()),
reason="This test is flaky on Ubuntu on GitHub Actions. See https://github.com/microsoft/hummingbird/pull/709 for more info.",
)
def test_random_forest_tvm_tree_trav_regressor_converter(self):
self._run_tree_regressor_converter(
RandomForestRegressor,
1000,
"tvm",
extra_config={constants.TREE_IMPLEMENTATION: "tree_trav", constants.TVM_MAX_FUSE_DEPTH: 30},
n_estimators=10,
)
# Random forest perf_tree_trav regressor
@unittest.skipIf(not (tvm_installed()), reason="TVM tests require TVM")
@unittest.skipIf(
((sys.platform == "linux") and is_on_github_actions()),
reason="This test is flaky on Ubuntu on GitHub Actions. See https://github.com/microsoft/hummingbird/pull/709 for more info.",
)
def test_random_forest_tvm_perf_tree_trav_regressor_converter(self):
self._run_tree_regressor_converter(
RandomForestRegressor,
1000,
"tvm",
extra_config={constants.TREE_IMPLEMENTATION: "perf_tree_trav", constants.TVM_MAX_FUSE_DEPTH: 10},
n_estimators=10,
)
# Extra trees gemm regressor
@unittest.skipIf(not (tvm_installed()), reason="TVM tests require TVM")
@unittest.skipIf(
((sys.platform == "linux") and is_on_github_actions()),
reason="This test is flaky on Ubuntu on GitHub Actions. See https://github.com/microsoft/hummingbird/pull/709 for more info.",
)
def test_extra_trees_tvm_gemm_regressor_converter(self):
self._run_tree_regressor_converter(
ExtraTreesRegressor,
1000,
"tvm",
extra_config={constants.TREE_IMPLEMENTATION: "gemm", constants.TVM_MAX_FUSE_DEPTH: 30},
n_estimators=10,
)
# Extra trees tree_trav regressor
@unittest.skipIf(not (tvm_installed()), reason="TVM tests require TVM")
@unittest.skipIf(
((sys.platform == "linux") and is_on_github_actions()),
reason="This test is flaky on Ubuntu on GitHub Actions. See https://github.com/microsoft/hummingbird/pull/709 for more info.",
)
def test_extra_trees_tvm_tree_trav_regressor_converter(self):
self._run_tree_regressor_converter(
ExtraTreesRegressor,
1000,
"tvm",
extra_config={constants.TREE_IMPLEMENTATION: "tree_trav", constants.TVM_MAX_FUSE_DEPTH: 30},
n_estimators=10,
)
# Extra trees perf_tree_trav regressor
@unittest.skipIf(not (tvm_installed()), reason="TVM tests require TVM")
@unittest.skipIf(
((sys.platform == "linux") and is_on_github_actions()),
reason="This test is flaky on Ubuntu on GitHub Actions. See https://github.com/microsoft/hummingbird/pull/709 for more info.",
)
def test_extra_trees_tvm_perf_tree_trav_regressor_converter(self):
self._run_tree_regressor_converter(
ExtraTreesRegressor,
1000,
"tvm",
extra_config={constants.TREE_IMPLEMENTATION: "perf_tree_trav", constants.TVM_MAX_FUSE_DEPTH: 10},
n_estimators=10,
)
# Decision tree regressor
@unittest.skipIf(not (tvm_installed()), reason="TVM tests require TVM")
@unittest.skipIf(
((sys.platform == "linux") and is_on_github_actions()),
reason="This test is flaky on Ubuntu on GitHub Actions. See https://github.com/microsoft/hummingbird/pull/709 for more info.",
)
def test_decision_tree_tvm_regressor_converter(self):
self._run_tree_regressor_converter(DecisionTreeRegressor, 1000, "tvm", extra_config={constants.TVM_MAX_FUSE_DEPTH: 30})
# Decision tree gemm regressor
@unittest.skipIf(not (tvm_installed()), reason="TVM tests require TVM")
@unittest.skipIf(
((sys.platform == "linux") and is_on_github_actions()),
reason="This test is flaky on Ubuntu on GitHub Actions. See https://github.com/microsoft/hummingbird/pull/709 for more info.",
)
def test_decision_tree_tvm_gemm_regressor_converter(self):
self._run_tree_regressor_converter(
DecisionTreeRegressor,
1000,
"tvm",
extra_config={constants.TREE_IMPLEMENTATION: "gemm", constants.TVM_MAX_FUSE_DEPTH: 30},
)
# Decision tree tree_trav regressor
@unittest.skipIf(not (tvm_installed()), reason="TVM tests require TVM")
@unittest.skipIf(
((sys.platform == "linux") and is_on_github_actions()),
reason="This test is flaky on Ubuntu on GitHub Actions. See https://github.com/microsoft/hummingbird/pull/709 for more info.",
)
def test_decision_tree_tvm_tree_trav_regressor_converter(self):
self._run_tree_regressor_converter(
DecisionTreeRegressor,
1000,
"tvm",
extra_config={constants.TREE_IMPLEMENTATION: "tree_trav", constants.TVM_MAX_FUSE_DEPTH: 30},
)
# Decision tree perf_tree_trav regressor
@unittest.skipIf(not (tvm_installed()), reason="TVM tests require TVM")
@unittest.skipIf(
((sys.platform == "linux") and is_on_github_actions()),
reason="This test is flaky on Ubuntu on GitHub Actions. See https://github.com/microsoft/hummingbird/pull/709 for more info.",
)
def test_decision_tree_tvm_perf_tree_trav_regressor_converter(self):
self._run_tree_regressor_converter(
DecisionTreeRegressor,
1000,
"tvm",
extra_config={constants.TREE_IMPLEMENTATION: "perf_tree_trav", constants.TVM_MAX_FUSE_DEPTH: 10},
)
# Decision tree classifier
@unittest.skipIf(not (tvm_installed()), reason="TVM tests require TVM")
@unittest.skipIf(
((sys.platform == "linux") and is_on_github_actions()),
reason="This test is flaky on Ubuntu on GitHub Actions. See https://github.com/microsoft/hummingbird/pull/709 for more info.",
)
def test_decision_tree_tvm_classifier_converter(self):
self._run_tree_classification_converter(
DecisionTreeClassifier, 3, "tvm", extra_config={constants.TVM_MAX_FUSE_DEPTH: 30}
)
# Extra trees classifier
@unittest.skipIf(not (tvm_installed()), reason="TVM tests require TVM")
@unittest.skipIf(
((sys.platform == "linux") and is_on_github_actions()),
reason="This test is flaky on Ubuntu on GitHub Actions. See https://github.com/microsoft/hummingbird/pull/709 for more info.",
)
def test_extra_trees_tvm_classifier_converter(self):
self._run_tree_classification_converter(
ExtraTreesClassifier, 3, "tvm", n_estimators=10, extra_config={constants.TVM_MAX_FUSE_DEPTH: 30}
)
# TreeRegressor multioutput regression
def test_tree_regressors_multioutput_regression(self):
for tree_method in ["gemm", "tree_trav", "perf_tree_trav"]:
for n_targets in [1, 2, 7]:
for tree_class in [DecisionTreeRegressor, ExtraTreesRegressor, RandomForestRegressor]:
seed = random.randint(0, 2**32 - 1)
if tree_method == "perf_tree_trav":
model = tree_class(random_state=seed, max_depth=10)
else:
model = tree_class(random_state=seed)
X, y = datasets.make_regression(
n_samples=100, n_features=10, n_informative=5, n_targets=n_targets, random_state=seed
)
model.fit(X, y)
X = X.astype('float32')
y = y.astype('float32')
torch_model = hummingbird.ml.convert(
model,
"torch",
extra_config={constants.TREE_IMPLEMENTATION: tree_method, constants.TREE_OP_PRECISION_DTYPE: "float64"}
)
self.assertTrue(torch_model is not None)
np.testing.assert_allclose(model.predict(X), torch_model.predict(X), rtol=1e-5, atol=1e-5, err_msg="{}/{}/{}/{}".format(tree_method, n_targets, tree_class, seed))
First commit into master (#38) * initial upload * dev branch workflow * Update README.md * starting to setup coverage * flake err cleanup * deleted more unused code * can't find a good githubactions coverage * can't find a good githubactions coverage * bug fixes * consolidating tests * XGB Regressor is failing * commiting lgbm regressor tests * using params * fixing lgbm max_depth bug * better test output. TODO: fix the max_depth for lgbm and xgb to not fall through to None, need to compute * adding failure case test. TODO: why does RF not have extra_config in regressor * pinning to xgboost .90 for now * refactoring tree's extra_config for xgb and lgbm * fixing reversed param * adding gbdt test file * refactoring beam params functions * making all beam params as numpy * increasing coverege by shifting label starts and by deleting unused model.infer_initial_types() * extra config for rf reg * flake8 * more error testing * using onnxconverter types instead of copypaste * more consolidation * more test coverage * first step in refactor * cleaning up batch params * adding beam++ to node size 1 test * there is a bug, documenting * renaming trees to match paper * test * adding precommit hooks * README.md * readme update * commit hooks * Fixing badge link to be relative * notebook for demo * notebook for demo * notebook params change * reveriting 2c95f488a4dc and reopening issue #9; this solution is too clunky * bumping pyt req * Fix pytorch requirements * Fix to brackets for alpha in xgboost * Few minor fixes to comments in tests * Removed unecessary regression tests * Add binary classification tests for gemm, tree_trav and perf_tree_trav * Fixes to whitespaces * updating readme * filling out contrib section * expanding readme example so that (1) it actually runs (2) it actually does a thing * cleaning notebook example * Fix to typo and update to the requirements * Fix to flake8 errors * readme changes from this morning * changes based on feedback * Few edits to contributing * Few edits in the README file * fixing mailto: syntax * Remove initial_types from the converter API * Rename Skl2PyTorch container into HBPyTorch * Add convert_xgboost and convert_lightgbm API * Fix to spacing * remove pandas check (for the moment) * fix import * Fix readme to use the new API * removed common directory * add some documentation * renamed few things * code refactoring for trees * refactor lightgbm and xgboost by moving stuff into gbdt_commons * done with a pass on gbdt after moving everything to _gbdt_common * final refactoring of gbdt classes * rename random forest stuff into decision tree * major refactoring for tree implementations * some renaming here and there * minor fix * Add test to validate that issue #7 is closed. * import container stuff from onnx-common * fix the parser to use the topology in onnx-common * remove unnecessary files * address first chunk of Karla's comments * fix typo in calibration * Another round of comments addressed * fix typo * these two lines seem unnecessary * moving notebooks from broken branch * adding notebooks with new API changes * removing comment * removed few unnecessary code and edited some documentation * Update CONTRIBUTING.md * remove . from git clone * Final pass over non-converters files documentation / API * add constants for converters * simplify a bit the API by using extra_config for optional parameters * Update CONTRIBUTING.md * done with documentation over public classes , methods * add contants and extra config management * addressing Karla's comments * pip install pdoc; pdoc --html hummingbird * pdoc3, using overrides to get extra doc if we want it * add few tests to check that we actually pick the correct implementation * Update README.md * Reformat doc * add HB logo to readme file * Add HB logo in doc * add assertion on model being not None Co-authored-by: Karla Saur <karla.saur@microsoft.com> Co-authored-by: Matteo Interlandi <mainterl@microsoft.com>
2020-04-29 19:09:41 +03:00
if __name__ == "__main__":
unittest.main()