def test_tree_ensemble_regressor_xgboost(self):

        this = os.path.dirname(__file__)
        data_train = pandas.read_csv(os.path.join(
            this, "xgboost.model.xgb.n4.d3.train.txt"),
                                     header=None)

        X = data_train.iloc[:, 1:].values
        y = data_train.iloc[:, 0].values

        params = dict(n_estimator=4, max_depth=3)
        model = XGBRegressor(**params).fit(X, y)
        # See https://github.com/apple/coremltools/issues/51.
        model.booster = model.get_booster
        model_coreml = convert_xgb_to_coreml(model)
        model_onnx = convert_cml(model_coreml)
        assert model_onnx is not None
Exemple #2
0
    def test_tree_ensemble_regressor_xgboost(self):

        this = os.path.dirname(__file__)
        data_train = pandas.read_csv(os.path.join(
            this, "xgboost.model.xgb.n4.d3.train.txt"),
                                     header=None)

        X = data_train.iloc[:, 1:].values
        y = data_train.iloc[:, 0].values

        params = dict(n_estimator=4, max_depth=3)
        model = XGBRegressor(**params).fit(X, y)
        # See https://github.com/apple/coremltools/issues/51.
        model.booster = model.get_booster
        model_coreml = convert_xgb_to_coreml(model)
        model_onnx = convert_cml(model_coreml)
        assert model_onnx is not None
        if sys.version_info[0] >= 3:
            # python 2.7 returns TypeError: can't pickle instancemethod objects
            dump_data_and_model(X.astype(numpy.float32),
                                model,
                                model_onnx,
                                basename="CmlXGBoostRegressor-OneOff-Reshape",
                                allow_failure=True)