├── pmml-xgboost ├── src │ ├── test │ │ ├── resources │ │ │ ├── csv │ │ │ │ ├── Iris.fmap │ │ │ │ ├── IrisNA.fmap │ │ │ │ ├── LungNA.fmap │ │ │ │ ├── Visit.fmap │ │ │ │ ├── VisitNA.fmap │ │ │ │ ├── MultiAutoNA.fmap │ │ │ │ ├── MultiAuto.fmap │ │ │ │ ├── Auto.fmap │ │ │ │ ├── AutoNA.fmap │ │ │ │ ├── MultiAuditNA.fmap │ │ │ │ ├── MultiAudit.fmap │ │ │ │ ├── AuditNA.fmap │ │ │ │ ├── Audit.fmap │ │ │ │ ├── AFTLungNA.csv │ │ │ │ ├── IrisNA.csv │ │ │ │ ├── Iris.csv │ │ │ │ ├── LinearRegressionAuto.csv │ │ │ │ ├── LinearRegressionAutoNA.csv │ │ │ │ ├── LungNA.csv │ │ │ │ ├── MultiLinearRegressionAutoNA.csv │ │ │ │ ├── MultiLinearRegressionAuto.csv │ │ │ │ ├── MultiRandomForestAutoNA.csv │ │ │ │ ├── MultiRandomForestAuto.csv │ │ │ │ └── MultinomialClassificationIris.csv │ │ │ ├── xgboost │ │ │ │ ├── AFTLungNA.ubj │ │ │ │ ├── AFTLungNA.model │ │ │ │ ├── GammaRegressionVisit.ubj │ │ │ │ ├── LinearRegressionAuto.ubj │ │ │ │ ├── GammaRegressionVisitNA.ubj │ │ │ │ ├── LinearRegressionAutoNA.ubj │ │ │ │ ├── MultiRandomForestAuto.ubj │ │ │ │ ├── PoissonRegressionVisit.ubj │ │ │ │ ├── TweedieRegressionVisit.ubj │ │ │ │ ├── HingeClassificationAudit.ubj │ │ │ │ ├── LogisticRegressionAudit.ubj │ │ │ │ ├── LogisticRegressionAuditNA.ubj │ │ │ │ ├── MultiLinearRegressionAuto.ubj │ │ │ │ ├── MultiRandomForestAutoNA.ubj │ │ │ │ ├── PoissonRegressionVisitNA.ubj │ │ │ │ ├── TweedieRegressionVisitNA.ubj │ │ │ │ ├── BinomialClassificationAudit.ubj │ │ │ │ ├── HingeClassificationAuditNA.ubj │ │ │ │ ├── MultiLinearRegressionAutoNA.ubj │ │ │ │ ├── BinomialClassificationAuditNA.ubj │ │ │ │ ├── MultinomialClassificationAudit.ubj │ │ │ │ ├── MultinomialClassificationIris.ubj │ │ │ │ ├── MultiBinomialClassificationAudit.ubj │ │ │ │ ├── MultinomialClassificationAuditNA.ubj │ │ │ │ ├── MultinomialClassificationIris.model │ │ │ │ ├── MultinomialClassificationIrisNA.ubj │ │ │ │ ├── MultiBinomialClassificationAuditNA.ubj │ │ │ │ └── MultinomialClassificationIrisNA.model │ │ │ └── data.R │ │ └── java │ │ │ └── org │ │ │ └── jpmml │ │ │ └── xgboost │ │ │ └── testing │ │ │ ├── XGBoostDatasets.java │ │ │ ├── XGBoostAlgorithms.java │ │ │ ├── MultiRegressionTest.java │ │ │ ├── MultiClassificationTest.java │ │ │ ├── RegressionTest.java │ │ │ └── ClassificationTest.java │ └── main │ │ └── java │ │ └── org │ │ └── jpmml │ │ └── xgboost │ │ ├── NodeStat.java │ │ ├── XGBoostEncoder.java │ │ ├── JSONLoadable.java │ │ ├── UBJSONLoadable.java │ │ ├── BinaryLoadable.java │ │ ├── testing │ │ ├── XGBoostFormats.java │ │ ├── XGBoostEncoderBatchTest.java │ │ └── XGBoostEncoderBatch.java │ │ ├── PoissonRegression.java │ │ ├── GradientBooster.java │ │ ├── LambdaMART.java │ │ ├── ByteOrderUtil.java │ │ ├── LinearRegression.java │ │ ├── BinaryNodeStat.java │ │ ├── IntegerRange.java │ │ ├── Node.java │ │ ├── Regression.java │ │ ├── HasXGBoostOptions.java │ │ ├── AFT.java │ │ ├── LogisticRegression.java │ │ ├── GeneralizedLinearRegression.java │ │ ├── BinomialLogisticRegression.java │ │ ├── Dart.java │ │ ├── BinaryNode.java │ │ ├── HingeClassification.java │ │ ├── MultinomialLogisticRegression.java │ │ ├── UBJSONUtil.java │ │ ├── JSONNode.java │ │ ├── Classification.java │ │ ├── visitors │ │ └── TreeModelCompactor.java │ │ ├── XGBoostUtil.java │ │ ├── XGBoostDataInput.java │ │ ├── ObjFunction.java │ │ └── GBTree.java └── pom.xml ├── .github └── workflows │ └── maven.yml ├── NEWS.md ├── pmml-xgboost-example ├── pom.xml └── src │ └── main │ └── java │ └── org │ └── jpmml │ └── xgboost │ └── example │ └── Main.java └── pom.xml /pmml-xgboost/src/test/resources/csv/Iris.fmap: -------------------------------------------------------------------------------- 1 | 0 Sepal.Length q 2 | 1 Sepal.Width q 3 | 2 Petal.Length q 4 | 3 Petal.Width q 5 | -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/csv/IrisNA.fmap: -------------------------------------------------------------------------------- 1 | 0 Sepal.Length q 2 | 1 Sepal.Width q 3 | 2 Petal.Length q 4 | 3 Petal.Width q 5 | -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/csv/LungNA.fmap: -------------------------------------------------------------------------------- 1 | 0 age int 2 | 1 sex int 3 | 2 ph.ecog q 4 | 3 ph.karno q 5 | 4 pat.karno q 6 | 5 meal.cal q 7 | 6 wt.loss q 8 | -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/AFTLungNA.ubj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/AFTLungNA.ubj -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/AFTLungNA.model: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/AFTLungNA.model -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/GammaRegressionVisit.ubj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/GammaRegressionVisit.ubj -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/LinearRegressionAuto.ubj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/LinearRegressionAuto.ubj -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/GammaRegressionVisitNA.ubj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/GammaRegressionVisitNA.ubj -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/LinearRegressionAutoNA.ubj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/LinearRegressionAutoNA.ubj -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/MultiRandomForestAuto.ubj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/MultiRandomForestAuto.ubj -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/PoissonRegressionVisit.ubj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/PoissonRegressionVisit.ubj -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/TweedieRegressionVisit.ubj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/TweedieRegressionVisit.ubj -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/HingeClassificationAudit.ubj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/HingeClassificationAudit.ubj -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/LogisticRegressionAudit.ubj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/LogisticRegressionAudit.ubj -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/LogisticRegressionAuditNA.ubj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/LogisticRegressionAuditNA.ubj -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/MultiLinearRegressionAuto.ubj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/MultiLinearRegressionAuto.ubj -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/MultiRandomForestAutoNA.ubj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/MultiRandomForestAutoNA.ubj -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/PoissonRegressionVisitNA.ubj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/PoissonRegressionVisitNA.ubj -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/TweedieRegressionVisitNA.ubj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/TweedieRegressionVisitNA.ubj -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/BinomialClassificationAudit.ubj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/BinomialClassificationAudit.ubj -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/HingeClassificationAuditNA.ubj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/HingeClassificationAuditNA.ubj -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/MultiLinearRegressionAutoNA.ubj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/MultiLinearRegressionAutoNA.ubj -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/BinomialClassificationAuditNA.ubj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/BinomialClassificationAuditNA.ubj -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/MultinomialClassificationAudit.ubj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/MultinomialClassificationAudit.ubj -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/MultinomialClassificationIris.ubj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/MultinomialClassificationIris.ubj -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/MultiBinomialClassificationAudit.ubj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/MultiBinomialClassificationAudit.ubj -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/MultinomialClassificationAuditNA.ubj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/MultinomialClassificationAuditNA.ubj -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/MultinomialClassificationIris.model: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/MultinomialClassificationIris.model -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/MultinomialClassificationIrisNA.ubj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/MultinomialClassificationIrisNA.ubj -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/MultiBinomialClassificationAuditNA.ubj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/MultiBinomialClassificationAuditNA.ubj -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/xgboost/MultinomialClassificationIrisNA.model: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpmml/jpmml-xgboost/HEAD/pmml-xgboost/src/test/resources/xgboost/MultinomialClassificationIrisNA.model -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/csv/Visit.fmap: -------------------------------------------------------------------------------- 1 | 0 edlevel=Coll/Univ i 2 | 1 edlevel=Grad_School i 3 | 2 edlevel=HS_grad i 4 | 3 edlevel=Not_HS_grad i 5 | 4 age int 6 | 5 outwork=0 i 7 | 6 outwork=1 i 8 | 7 female=0 i 9 | 8 female=1 i 10 | 9 married=0 i 11 | 10 married=1 i 12 | 11 kids=0 i 13 | 12 kids=1 i 14 | 13 hhninc q 15 | 14 educ q 16 | 15 self=0 i 17 | 16 self=1 i 18 | -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/csv/VisitNA.fmap: -------------------------------------------------------------------------------- 1 | 0 edlevel=Coll/Univ i 2 | 1 edlevel=Grad_School i 3 | 2 edlevel=HS_grad i 4 | 3 edlevel=Not_HS_grad i 5 | 4 age q 6 | 5 outwork=0 i 7 | 6 outwork=1 i 8 | 7 female=0 i 9 | 8 female=1 i 10 | 9 married=0 i 11 | 10 married=1 i 12 | 11 kids=0 i 13 | 12 kids=1 i 14 | 13 hhninc q 15 | 14 educ q 16 | 15 self=0 i 17 | 16 self=1 i 18 | -------------------------------------------------------------------------------- /.github/workflows/maven.yml: -------------------------------------------------------------------------------- 1 | name: maven 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | 7 | jobs: 8 | build: 9 | 10 | runs-on: ubuntu-latest 11 | strategy: 12 | matrix: 13 | java: [ 11, 17, 21 ] 14 | 15 | steps: 16 | - uses: actions/checkout@v4 17 | - uses: actions/setup-java@v4 18 | with: 19 | distribution: 'zulu' 20 | java-version: ${{ matrix.java }} 21 | cache: 'maven' 22 | - run: mvn -B package --file pom.xml 23 | -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/csv/MultiAutoNA.fmap: -------------------------------------------------------------------------------- 1 | 0 cylinders=3 i 2 | 1 cylinders=4 i 3 | 2 cylinders=5 i 4 | 3 cylinders=6 i 5 | 4 cylinders=8 i 6 | 5 displacement q 7 | 6 horsepower q 8 | 7 weight q 9 | 8 model_year=70 i 10 | 9 model_year=71 i 11 | 10 model_year=72 i 12 | 11 model_year=73 i 13 | 12 model_year=74 i 14 | 13 model_year=75 i 15 | 14 model_year=76 i 16 | 15 model_year=77 i 17 | 16 model_year=78 i 18 | 17 model_year=79 i 19 | 18 model_year=80 i 20 | 19 model_year=81 i 21 | 20 model_year=82 i 22 | 21 origin=1 i 23 | 22 origin=2 i 24 | 23 origin=3 i 25 | -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/csv/MultiAuto.fmap: -------------------------------------------------------------------------------- 1 | 0 cylinders=3 i 2 | 1 cylinders=4 i 3 | 2 cylinders=5 i 4 | 3 cylinders=6 i 5 | 4 cylinders=8 i 6 | 5 displacement q 7 | 6 horsepower int 8 | 7 weight int 9 | 8 model_year=70 i 10 | 9 model_year=71 i 11 | 10 model_year=72 i 12 | 11 model_year=73 i 13 | 12 model_year=74 i 14 | 13 model_year=75 i 15 | 14 model_year=76 i 16 | 15 model_year=77 i 17 | 16 model_year=78 i 18 | 17 model_year=79 i 19 | 18 model_year=80 i 20 | 19 model_year=81 i 21 | 20 model_year=82 i 22 | 21 origin=1 i 23 | 22 origin=2 i 24 | 23 origin=3 i 25 | -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/csv/Auto.fmap: -------------------------------------------------------------------------------- 1 | 0 cylinders=3 i 2 | 1 cylinders=4 i 3 | 2 cylinders=5 i 4 | 3 cylinders=6 i 5 | 4 cylinders=8 i 6 | 5 displacement q 7 | 6 horsepower int 8 | 7 weight int 9 | 8 acceleration q 10 | 9 model_year=70 i 11 | 10 model_year=71 i 12 | 11 model_year=72 i 13 | 12 model_year=73 i 14 | 13 model_year=74 i 15 | 14 model_year=75 i 16 | 15 model_year=76 i 17 | 16 model_year=77 i 18 | 17 model_year=78 i 19 | 18 model_year=79 i 20 | 19 model_year=80 i 21 | 20 model_year=81 i 22 | 21 model_year=82 i 23 | 22 origin=1 i 24 | 23 origin=2 i 25 | 24 origin=3 i 26 | -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/csv/AutoNA.fmap: -------------------------------------------------------------------------------- 1 | 0 cylinders=3 i 2 | 1 cylinders=4 i 3 | 2 cylinders=5 i 4 | 3 cylinders=6 i 5 | 4 cylinders=8 i 6 | 5 displacement q 7 | 6 horsepower q 8 | 7 weight q 9 | 8 acceleration q 10 | 9 model_year=70 i 11 | 10 model_year=71 i 12 | 11 model_year=72 i 13 | 12 model_year=73 i 14 | 13 model_year=74 i 15 | 14 model_year=75 i 16 | 15 model_year=76 i 17 | 16 model_year=77 i 18 | 17 model_year=78 i 19 | 18 model_year=79 i 20 | 19 model_year=80 i 21 | 20 model_year=81 i 22 | 21 model_year=82 i 23 | 22 origin=1 i 24 | 23 origin=2 i 25 | 24 origin=3 i 26 | -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/NodeStat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | abstract 22 | public class NodeStat { 23 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/XGBoostEncoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import org.jpmml.converter.ModelEncoder; 22 | 23 | public class XGBoostEncoder extends ModelEncoder { 24 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/JSONLoadable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import com.google.gson.JsonObject; 22 | 23 | public interface JSONLoadable { 24 | 25 | void loadJSON(JsonObject object); 26 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/UBJSONLoadable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import com.devsmart.ubjson.UBObject; 22 | 23 | public interface UBJSONLoadable { 24 | 25 | void loadUBJSON(UBObject object); 26 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/BinaryLoadable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import java.io.IOException; 22 | 23 | public interface BinaryLoadable { 24 | 25 | void loadBinary(XGBoostDataInput input) throws IOException; 26 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/testing/XGBoostFormats.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost.testing; 20 | 21 | public interface XGBoostFormats { 22 | 23 | String BINARY = "model"; 24 | String JSON = "json"; 25 | String UBJSON = "ubj"; 26 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/PoissonRegression.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | public class PoissonRegression extends GeneralizedLinearRegression { 22 | 23 | public PoissonRegression(String name){ 24 | super(name); 25 | } 26 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/GradientBooster.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | abstract 22 | public class GradientBooster implements BinaryLoadable, JSONLoadable, UBJSONLoadable { 23 | 24 | abstract 25 | public String getAlgorithmName(); 26 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/data.R: -------------------------------------------------------------------------------- 1 | library("COUNT") 2 | library("survival") 3 | 4 | data("lung") 5 | data("rwm1984") 6 | 7 | loadVisit = function(){ 8 | visit = data.frame(rwm1984) 9 | visit$edlevel = factor(visit$edlevel, labels = c("Not HS grad", "HS grad", "Coll/Univ", "Grad School")) 10 | visit$edlevel1 = NULL 11 | visit$edlevel2 = NULL 12 | visit$edlevel3 = NULL 13 | visit$edlevel4 = NULL 14 | visit$hospvis = NULL 15 | 16 | # Move docvis from the first position to the last position 17 | visit = visit[, c(2:ncol(visit), 1)] 18 | 19 | return (visit) 20 | } 21 | 22 | visit = loadVisit() 23 | 24 | # Drop rows with 0 counts 25 | visit = visit[visit$docvis > 0, ] 26 | 27 | write.table(visit, "csv/Visit.csv", sep = ",", quote = FALSE, row.names = FALSE) 28 | 29 | loadLung = function(){ 30 | lung = data.frame(lung) 31 | lung$inst = NULL 32 | lung$sex = as.factor(lung$sex) 33 | lung$status = as.factor(lung$status - 1) 34 | 35 | # Move time and status from the first position to the last position 36 | lung = lung[, c(3:ncol(lung), 1, 2)] 37 | 38 | return (lung) 39 | } 40 | 41 | lung = loadLung() 42 | 43 | write.table(lung, "csv/LungNA.csv", sep = ",", quote = FALSE, row.names = FALSE) 44 | -------------------------------------------------------------------------------- /pmml-xgboost/src/test/java/org/jpmml/xgboost/testing/XGBoostDatasets.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost.testing; 20 | 21 | import org.jpmml.converter.testing.Datasets; 22 | 23 | public interface XGBoostDatasets extends Datasets { 24 | 25 | String AUDIT_LIMIT = AUDIT + "@31"; 26 | String AUDIT_NA_LIMIT = AUDIT_NA + "@31"; 27 | String IRIS_LIMIT = IRIS + "@11"; 28 | String IRIS_NA_LIMIT = IRIS_NA + "@11"; 29 | String LUNG = "Lung"; 30 | String LUNG_NA = LUNG + "NA"; 31 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/csv/MultiAuditNA.fmap: -------------------------------------------------------------------------------- 1 | 0 Age q 2 | 1 Employment=Consultant i 3 | 2 Employment=PSFederal i 4 | 3 Employment=PSLocal i 5 | 4 Employment=PSState i 6 | 5 Employment=Private i 7 | 6 Employment=SelfEmp i 8 | 7 Employment=Volunteer i 9 | 8 Education=Associate i 10 | 9 Education=Bachelor i 11 | 10 Education=College i 12 | 11 Education=Doctorate i 13 | 12 Education=HSgrad i 14 | 13 Education=Master i 15 | 14 Education=Preschool i 16 | 15 Education=Professional i 17 | 16 Education=Vocational i 18 | 17 Education=Yr10 i 19 | 18 Education=Yr11 i 20 | 19 Education=Yr12 i 21 | 20 Education=Yr1t4 i 22 | 21 Education=Yr5t6 i 23 | 22 Education=Yr7t8 i 24 | 23 Education=Yr9 i 25 | 24 Marital=Absent i 26 | 25 Marital=Divorced i 27 | 26 Marital=Married i 28 | 27 Marital=Married-spouse-absent i 29 | 28 Marital=Unmarried i 30 | 29 Marital=Widowed i 31 | 30 Occupation=Cleaner i 32 | 31 Occupation=Clerical i 33 | 32 Occupation=Executive i 34 | 33 Occupation=Farming i 35 | 34 Occupation=Home i 36 | 35 Occupation=Machinist i 37 | 36 Occupation=Military i 38 | 37 Occupation=Professional i 39 | 38 Occupation=Protective i 40 | 39 Occupation=Repair i 41 | 40 Occupation=Sales i 42 | 41 Occupation=Service i 43 | 42 Occupation=Support i 44 | 43 Occupation=Transport i 45 | 44 Income q 46 | 45 Hours q 47 | -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/csv/MultiAudit.fmap: -------------------------------------------------------------------------------- 1 | 0 Age int 2 | 1 Employment=Consultant i 3 | 2 Employment=PSFederal i 4 | 3 Employment=PSLocal i 5 | 4 Employment=PSState i 6 | 5 Employment=Private i 7 | 6 Employment=SelfEmp i 8 | 7 Employment=Volunteer i 9 | 8 Education=Associate i 10 | 9 Education=Bachelor i 11 | 10 Education=College i 12 | 11 Education=Doctorate i 13 | 12 Education=HSgrad i 14 | 13 Education=Master i 15 | 14 Education=Preschool i 16 | 15 Education=Professional i 17 | 16 Education=Vocational i 18 | 17 Education=Yr10 i 19 | 18 Education=Yr11 i 20 | 19 Education=Yr12 i 21 | 20 Education=Yr1t4 i 22 | 21 Education=Yr5t6 i 23 | 22 Education=Yr7t8 i 24 | 23 Education=Yr9 i 25 | 24 Marital=Absent i 26 | 25 Marital=Divorced i 27 | 26 Marital=Married i 28 | 27 Marital=Married-spouse-absent i 29 | 28 Marital=Unmarried i 30 | 29 Marital=Widowed i 31 | 30 Occupation=Cleaner i 32 | 31 Occupation=Clerical i 33 | 32 Occupation=Executive i 34 | 33 Occupation=Farming i 35 | 34 Occupation=Home i 36 | 35 Occupation=Machinist i 37 | 36 Occupation=Military i 38 | 37 Occupation=Professional i 39 | 38 Occupation=Protective i 40 | 39 Occupation=Repair i 41 | 40 Occupation=Sales i 42 | 41 Occupation=Service i 43 | 42 Occupation=Support i 44 | 43 Occupation=Transport i 45 | 44 Income q 46 | 45 Deductions i 47 | 46 Hours int 48 | -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/csv/AuditNA.fmap: -------------------------------------------------------------------------------- 1 | 0 Age q 2 | 1 Employment=Consultant i 3 | 2 Employment=PSFederal i 4 | 3 Employment=PSLocal i 5 | 4 Employment=PSState i 6 | 5 Employment=Private i 7 | 6 Employment=SelfEmp i 8 | 7 Employment=Volunteer i 9 | 8 Education=Associate i 10 | 9 Education=Bachelor i 11 | 10 Education=College i 12 | 11 Education=Doctorate i 13 | 12 Education=HSgrad i 14 | 13 Education=Master i 15 | 14 Education=Preschool i 16 | 15 Education=Professional i 17 | 16 Education=Vocational i 18 | 17 Education=Yr10 i 19 | 18 Education=Yr11 i 20 | 19 Education=Yr12 i 21 | 20 Education=Yr1t4 i 22 | 21 Education=Yr5t6 i 23 | 22 Education=Yr7t8 i 24 | 23 Education=Yr9 i 25 | 24 Marital=Absent i 26 | 25 Marital=Divorced i 27 | 26 Marital=Married i 28 | 27 Marital=Married-spouse-absent i 29 | 28 Marital=Unmarried i 30 | 29 Marital=Widowed i 31 | 30 Occupation=Cleaner i 32 | 31 Occupation=Clerical i 33 | 32 Occupation=Executive i 34 | 33 Occupation=Farming i 35 | 34 Occupation=Home i 36 | 35 Occupation=Machinist i 37 | 36 Occupation=Military i 38 | 37 Occupation=Professional i 39 | 38 Occupation=Protective i 40 | 39 Occupation=Repair i 41 | 40 Occupation=Sales i 42 | 41 Occupation=Service i 43 | 42 Occupation=Support i 44 | 43 Occupation=Transport i 45 | 44 Income q 46 | 45 Gender=Female i 47 | 46 Gender=Male i 48 | 47 Hours q 49 | -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/csv/Audit.fmap: -------------------------------------------------------------------------------- 1 | 0 Age int 2 | 1 Employment=Consultant i 3 | 2 Employment=PSFederal i 4 | 3 Employment=PSLocal i 5 | 4 Employment=PSState i 6 | 5 Employment=Private i 7 | 6 Employment=SelfEmp i 8 | 7 Employment=Volunteer i 9 | 8 Education=Associate i 10 | 9 Education=Bachelor i 11 | 10 Education=College i 12 | 11 Education=Doctorate i 13 | 12 Education=HSgrad i 14 | 13 Education=Master i 15 | 14 Education=Preschool i 16 | 15 Education=Professional i 17 | 16 Education=Vocational i 18 | 17 Education=Yr10 i 19 | 18 Education=Yr11 i 20 | 19 Education=Yr12 i 21 | 20 Education=Yr1t4 i 22 | 21 Education=Yr5t6 i 23 | 22 Education=Yr7t8 i 24 | 23 Education=Yr9 i 25 | 24 Marital=Absent i 26 | 25 Marital=Divorced i 27 | 26 Marital=Married i 28 | 27 Marital=Married-spouse-absent i 29 | 28 Marital=Unmarried i 30 | 29 Marital=Widowed i 31 | 30 Occupation=Cleaner i 32 | 31 Occupation=Clerical i 33 | 32 Occupation=Executive i 34 | 33 Occupation=Farming i 35 | 34 Occupation=Home i 36 | 35 Occupation=Machinist i 37 | 36 Occupation=Military i 38 | 37 Occupation=Professional i 39 | 38 Occupation=Protective i 40 | 39 Occupation=Repair i 41 | 40 Occupation=Sales i 42 | 41 Occupation=Service i 43 | 42 Occupation=Support i 44 | 43 Occupation=Transport i 45 | 44 Income q 46 | 45 Gender=Female i 47 | 46 Gender=Male i 48 | 47 Deductions i 49 | 48 Hours int 50 | -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/LambdaMART.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import java.util.List; 22 | 23 | import org.dmg.pmml.mining.MiningModel; 24 | import org.jpmml.converter.Schema; 25 | 26 | public class LambdaMART extends Regression { 27 | 28 | public LambdaMART(String name){ 29 | super(name); 30 | } 31 | 32 | @Override 33 | public MiningModel encodeModel(List trees, List weights, float[] base_score, Integer ntreeLimit, Schema schema){ 34 | MiningModel miningModel = createMiningModel(trees, weights, base_score, ntreeLimit, schema); 35 | 36 | return miningModel; 37 | } 38 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/ByteOrderUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import java.nio.ByteOrder; 22 | 23 | public class ByteOrderUtil { 24 | 25 | private ByteOrderUtil(){ 26 | } 27 | 28 | static 29 | public ByteOrder forValue(String value){ 30 | 31 | if(("BIG_ENDIAN").equalsIgnoreCase(value) || ("BE").equalsIgnoreCase(value)){ 32 | return ByteOrder.BIG_ENDIAN; 33 | } else 34 | 35 | if(("LITTLE_ENDIAN").equalsIgnoreCase(value) || ("LE").equalsIgnoreCase(value)){ 36 | return ByteOrder.LITTLE_ENDIAN; 37 | } else 38 | 39 | { 40 | throw new IllegalArgumentException(value); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/LinearRegression.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import java.util.List; 22 | 23 | import org.dmg.pmml.mining.MiningModel; 24 | import org.jpmml.converter.Schema; 25 | 26 | public class LinearRegression extends Regression { 27 | 28 | public LinearRegression(String name){ 29 | super(name); 30 | } 31 | 32 | @Override 33 | public MiningModel encodeModel(List trees, List weights, float[] base_score, Integer ntreeLimit, Schema schema){ 34 | MiningModel miningModel = createMiningModel(trees, weights, base_score, ntreeLimit, schema); 35 | 36 | return miningModel; 37 | } 38 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/BinaryNodeStat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import java.io.IOException; 22 | 23 | public class BinaryNodeStat extends NodeStat implements BinaryLoadable { 24 | 25 | private float loss_chg; 26 | 27 | private float sum_hess; 28 | 29 | private float base_weight; 30 | 31 | private int leaf_child_cnt; 32 | 33 | 34 | public BinaryNodeStat(){ 35 | } 36 | 37 | @Override 38 | public void loadBinary(XGBoostDataInput input) throws IOException { 39 | this.loss_chg = input.readFloat(); 40 | this.sum_hess = input.readFloat(); 41 | this.base_weight = input.readFloat(); 42 | this.leaf_child_cnt = input.readInt(); 43 | } 44 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/test/java/org/jpmml/xgboost/testing/XGBoostAlgorithms.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost.testing; 20 | 21 | public interface XGBoostAlgorithms { 22 | 23 | String AFT = "AFT"; 24 | String BINOMIAL_CLASSIFICATION = "BinomialClassification"; 25 | String GAMMA_REGRESSION = "GammaRegression"; 26 | String HINGE_CLASSIFICATION = "HingeClassification"; 27 | String LINEAR_REGRESSION = "LinearRegression"; 28 | String LOGISTIC_REGRESSION = "LogisticRegression"; 29 | String MULTINOMIAL_CLASSIFICATION = "MultinomialClassification"; 30 | String POISSON_REGRESSION = "PoissonRegression"; 31 | String RANDOM_FOREST = "RandomForest"; 32 | String TWEEDIE_REGRESSION = "TweedieRegression"; 33 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/IntegerRange.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import java.util.AbstractList; 22 | 23 | class IntegerRange extends AbstractList { 24 | 25 | private int size; 26 | 27 | 28 | IntegerRange(int size){ 29 | 30 | if(size < 0){ 31 | throw new IllegalArgumentException(); 32 | } 33 | 34 | this.size = size; 35 | } 36 | 37 | @Override 38 | public boolean isEmpty(){ 39 | return (this.size == 0); 40 | } 41 | 42 | @Override 43 | public int size(){ 44 | return this.size; 45 | } 46 | 47 | @Override 48 | public Integer get(int i){ 49 | 50 | if(i < 0 || i >= this.size){ 51 | throw new IndexOutOfBoundsException(); 52 | } 53 | 54 | return i; 55 | } 56 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/Node.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import java.util.BitSet; 22 | 23 | abstract 24 | public class Node { 25 | 26 | abstract 27 | public boolean is_leaf(); 28 | 29 | abstract 30 | public float leaf_value(); 31 | 32 | abstract 33 | public int left_child(); 34 | 35 | abstract 36 | public int right_child(); 37 | 38 | abstract 39 | public boolean default_left(); 40 | 41 | abstract 42 | public int split_index(); 43 | 44 | abstract 45 | public int split_type(); 46 | 47 | abstract 48 | public int split_cond(); 49 | 50 | abstract 51 | public BitSet get_split_categories(); 52 | 53 | public static final int SPLIT_NUMERICAL = 0; 54 | public static final int SPLIT_CATEGORICAL = 1; 55 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/Regression.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import java.util.List; 22 | 23 | import org.dmg.pmml.DataField; 24 | import org.dmg.pmml.DataType; 25 | import org.dmg.pmml.OpType; 26 | import org.jpmml.converter.ContinuousLabel; 27 | import org.jpmml.converter.Label; 28 | import org.jpmml.converter.ModelEncoder; 29 | 30 | abstract 31 | public class Regression extends ObjFunction { 32 | 33 | public Regression(String name){ 34 | super(name); 35 | } 36 | 37 | @Override 38 | public Label encodeLabel(String targetName, List targetCategories, ModelEncoder encoder){ 39 | 40 | if(targetCategories != null){ 41 | throw new IllegalArgumentException("Regression requires zero target categories"); 42 | } 43 | 44 | DataField dataField = encoder.createDataField(targetName, OpType.CONTINUOUS, DataType.FLOAT); 45 | 46 | return new ContinuousLabel(dataField); 47 | } 48 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/testing/XGBoostEncoderBatchTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost.testing; 20 | 21 | import java.util.function.Predicate; 22 | 23 | import com.google.common.base.Equivalence; 24 | import org.jpmml.converter.testing.ModelEncoderBatchTest; 25 | import org.jpmml.evaluator.ResultField; 26 | 27 | public class XGBoostEncoderBatchTest extends ModelEncoderBatchTest { 28 | 29 | public XGBoostEncoderBatchTest(Equivalence equivalence){ 30 | super(equivalence); 31 | } 32 | 33 | @Override 34 | public XGBoostEncoderBatch createBatch(String algorithm, String dataset, Predicate columnFilter, Equivalence equivalence){ 35 | XGBoostEncoderBatch result = new XGBoostEncoderBatch(algorithm, dataset, columnFilter, equivalence){ 36 | 37 | @Override 38 | public XGBoostEncoderBatchTest getArchiveBatchTest(){ 39 | return XGBoostEncoderBatchTest.this; 40 | } 41 | }; 42 | 43 | return result; 44 | } 45 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/HasXGBoostOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import java.util.LinkedHashMap; 22 | import java.util.Map; 23 | 24 | import org.jpmml.converter.HasNativeConfiguration; 25 | import org.jpmml.converter.HasOptions; 26 | 27 | public interface HasXGBoostOptions extends HasOptions, HasNativeConfiguration { 28 | 29 | String OPTION_BYTE_ORDER = "byte_order"; 30 | 31 | String OPTION_CHARSET = "charset"; 32 | 33 | String OPTION_COMPACT = "compact"; 34 | 35 | String OPTION_INPUT_FLOAT = "input_float"; 36 | 37 | String OPTION_MISSING = "missing"; 38 | 39 | String OPTION_NTREE_LIMIT = "ntree_limit"; 40 | 41 | String OPTION_NUMERIC = "numeric"; 42 | 43 | String OPTION_PRUNE = "prune"; 44 | 45 | @Override 46 | default 47 | public Map getNativeConfiguration(){ 48 | Map result = new LinkedHashMap<>(); 49 | result.put(HasXGBoostOptions.OPTION_COMPACT, Boolean.FALSE); 50 | 51 | return result; 52 | } 53 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/AFT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import java.util.List; 22 | 23 | import org.dmg.pmml.DataType; 24 | import org.dmg.pmml.OpType; 25 | import org.dmg.pmml.mining.MiningModel; 26 | import org.dmg.pmml.regression.RegressionModel; 27 | import org.jpmml.converter.ModelUtil; 28 | import org.jpmml.converter.Schema; 29 | import org.jpmml.converter.mining.MiningModelUtil; 30 | 31 | public class AFT extends Regression { 32 | 33 | public AFT(String name){ 34 | super(name); 35 | } 36 | 37 | @Override 38 | public ProbToMarginFunction probToMarginFunction(){ 39 | return (x) -> inverseExp(x); 40 | } 41 | 42 | @Override 43 | public MiningModel encodeModel(List trees, List weights, float[] base_score, Integer ntreeLimit, Schema schema){ 44 | Schema segmentSchema = schema.toAnonymousSchema(); 45 | 46 | MiningModel miningModel = createMiningModel(trees, weights, base_score, ntreeLimit, segmentSchema) 47 | .setOutput(ModelUtil.createPredictedOutput("xgbValue", OpType.CONTINUOUS, DataType.FLOAT)); 48 | 49 | return MiningModelUtil.createRegression(miningModel, RegressionModel.NormalizationMethod.EXP, schema); 50 | } 51 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/LogisticRegression.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import java.util.List; 22 | 23 | import org.dmg.pmml.DataType; 24 | import org.dmg.pmml.OpType; 25 | import org.dmg.pmml.mining.MiningModel; 26 | import org.dmg.pmml.regression.RegressionModel; 27 | import org.jpmml.converter.ModelUtil; 28 | import org.jpmml.converter.Schema; 29 | import org.jpmml.converter.mining.MiningModelUtil; 30 | 31 | public class LogisticRegression extends Regression { 32 | 33 | public LogisticRegression(String name){ 34 | super(name); 35 | } 36 | 37 | @Override 38 | public ProbToMarginFunction probToMarginFunction(){ 39 | return (x) -> inverseLogit(x); 40 | } 41 | 42 | @Override 43 | public MiningModel encodeModel(List trees, List weights, float[] base_score, Integer ntreeLimit, Schema schema){ 44 | Schema segmentSchema = schema.toAnonymousSchema(); 45 | 46 | MiningModel miningModel = createMiningModel(trees, weights, base_score, ntreeLimit, segmentSchema) 47 | .setOutput(ModelUtil.createPredictedOutput("xgbValue", OpType.CONTINUOUS, DataType.FLOAT)); 48 | 49 | return MiningModelUtil.createRegression(miningModel, RegressionModel.NormalizationMethod.LOGIT, schema); 50 | } 51 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/GeneralizedLinearRegression.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import java.util.List; 22 | 23 | import org.dmg.pmml.DataType; 24 | import org.dmg.pmml.OpType; 25 | import org.dmg.pmml.mining.MiningModel; 26 | import org.dmg.pmml.regression.RegressionModel; 27 | import org.jpmml.converter.ModelUtil; 28 | import org.jpmml.converter.Schema; 29 | import org.jpmml.converter.mining.MiningModelUtil; 30 | 31 | public class GeneralizedLinearRegression extends Regression { 32 | 33 | public GeneralizedLinearRegression(String name){ 34 | super(name); 35 | } 36 | 37 | @Override 38 | public ProbToMarginFunction probToMarginFunction(){ 39 | return x -> inverseExp(x); 40 | } 41 | 42 | @Override 43 | public MiningModel encodeModel(List trees, List weights, float[] base_score, Integer ntreeLimit, Schema schema){ 44 | Schema segmentSchema = schema.toAnonymousSchema(); 45 | 46 | MiningModel miningModel = createMiningModel(trees, weights, base_score, ntreeLimit, segmentSchema) 47 | .setOutput(ModelUtil.createPredictedOutput("xgbValue", OpType.CONTINUOUS, DataType.FLOAT)); 48 | 49 | return MiningModelUtil.createRegression(miningModel, RegressionModel.NormalizationMethod.EXP, schema); 50 | } 51 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/BinomialLogisticRegression.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import java.util.List; 22 | 23 | import org.dmg.pmml.DataType; 24 | import org.dmg.pmml.OpType; 25 | import org.dmg.pmml.mining.MiningModel; 26 | import org.dmg.pmml.regression.RegressionModel; 27 | import org.jpmml.converter.ModelUtil; 28 | import org.jpmml.converter.Schema; 29 | import org.jpmml.converter.mining.MiningModelUtil; 30 | 31 | public class BinomialLogisticRegression extends Classification { 32 | 33 | public BinomialLogisticRegression(String name){ 34 | super(name, 2); 35 | } 36 | 37 | @Override 38 | public ProbToMarginFunction probToMarginFunction(){ 39 | return (x) -> inverseLogit(x); 40 | } 41 | 42 | @Override 43 | public MiningModel encodeModel(List trees, List weights, float[] base_score, Integer ntreeLimit, Schema schema){ 44 | Schema segmentSchema = schema.toAnonymousRegressorSchema(DataType.FLOAT); 45 | 46 | MiningModel miningModel = createMiningModel(trees, weights, base_score, ntreeLimit, segmentSchema) 47 | .setOutput(ModelUtil.createPredictedOutput("xgbValue", OpType.CONTINUOUS, DataType.FLOAT)); 48 | 49 | return MiningModelUtil.createBinaryLogisticClassification(miningModel, 1d, 0d, RegressionModel.NormalizationMethod.LOGIT, true, schema); 50 | } 51 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/Dart.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import java.io.IOException; 22 | 23 | import com.devsmart.ubjson.GsonUtil; 24 | import com.devsmart.ubjson.UBObject; 25 | import com.devsmart.ubjson.UBValue; 26 | import com.google.gson.JsonObject; 27 | 28 | public class Dart extends GBTree { 29 | 30 | private float[] weight_drop; 31 | 32 | 33 | public Dart(){ 34 | } 35 | 36 | @Override 37 | public String getAlgorithmName(){ 38 | return "DART"; 39 | } 40 | 41 | @Override 42 | public void loadBinary(XGBoostDataInput input) throws IOException { 43 | super.loadBinary(input); 44 | 45 | int num_trees = num_trees(); 46 | if(num_trees != 0){ 47 | this.weight_drop = input.readFloatVector(); 48 | } 49 | } 50 | 51 | @Override 52 | public void loadJSON(JsonObject gradientBooster){ 53 | UBValue value = GsonUtil.toUBValue(gradientBooster); 54 | 55 | loadUBJSON(value.asObject()); 56 | } 57 | 58 | @Override 59 | public void loadUBJSON(UBObject gradientBooster){ 60 | UBObject gbtree = gradientBooster.get("gbtree").asObject(); 61 | 62 | super.loadUBJSON(gbtree); 63 | 64 | this.weight_drop = UBJSONUtil.toFloatArray(gradientBooster.get("weight_drop")); 65 | } 66 | 67 | @Override 68 | public float[] tree_weights(){ 69 | return this.weight_drop; 70 | } 71 | } -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # 1.8.2 # 2 | 3 | ## Breaking changes 4 | 5 | None. 6 | 7 | ## New features 8 | 9 | * Added support for [One-Model-Per-Target (OMPT)](https://xgboost.readthedocs.io/en/stable/tutorials/multioutput.html#training-with-one-model-per-target)-style multi-target models: 10 | * Regression 11 | * Binary classification 12 | 13 | See https://github.com/jpmml/jpmml-xgboost/issues/70 14 | 15 | * Improved support for random forest-style models. 16 | 17 | XGBoost boosting and bagging model files are structurally identical. 18 | 19 | The two model types can be told apart from one another by observing the value of the `/learner/gradient_booster/gbtree/model/gbtree_model_param/num_parallel_tree` integer attribute. 20 | Boosting models have it set to `1`, whereas bagging models (eg. random forests) have it set to the number of member decision trees models in the ensemble model, 21 | 22 | All the member decision tree models are stored in a `gbtree/model/trees` array attribute. 23 | When dealing with OMPT-style multi-target models, then the model converter must partition the contents of this attribute into multiple sub-arrays, one for each target. 24 | 25 | Currently, the partitioning algorithm is a little shaky. 26 | Integration tests confirm its correctness for "pure boosting" and "pure bagging" sub-types. However, it may yield incorrect results for the mixed "boosted bagging" sub-type. 27 | 28 | * Improved support for early stopping. 29 | 30 | If the training process was halted using the early stopping mechanism, then this is indicated by setting the `best_iteration` and `best_score` attributes on the native booster object. 31 | 32 | XGBoost 1.X versions tended to duplicate this information at the Python wrapper object level. 33 | For example, in the form of a `xgboost.core.Booster.best_ntree_limit` attribute. 34 | 35 | XGBoost 2.X versions no longer do this. 36 | The converter must now check for the early stopping status by loading the native booster object and querying its `/learner/attributes/best_iteration` and `/learner/attributes/best_score` attributes. 37 | 38 | ## Minor improvements and fixes 39 | 40 | * Updated integration testing resources to XGBoost 2.0.3 41 | -------------------------------------------------------------------------------- /pmml-xgboost/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.jpmml 7 | jpmml-xgboost 8 | 1.9-SNAPSHOT 9 | 10 | 11 | org.jpmml 12 | pmml-xgboost 13 | jar 14 | 15 | JPMML XGBoost converter 16 | JPMML XGBoost to PMML converter 17 | 18 | 19 | 20 | GNU Affero General Public License (AGPL) version 3.0 21 | http://www.gnu.org/licenses/agpl-3.0.html 22 | repo 23 | 24 | 25 | 26 | 27 | 28 | org.jpmml 29 | pmml-converter 30 | 31 | 32 | org.jpmml 33 | pmml-converter-testing 34 | 35 | 36 | 37 | org.jpmml 38 | pmml-evaluator-testing 39 | provided 40 | 41 | 42 | 43 | com.dev-smart 44 | ubjson 45 | 46 | 47 | com.dev-smart 48 | ubjson-gson 49 | 50 | 51 | 52 | com.google.code.gson 53 | gson 54 | 55 | 56 | 57 | 58 | 59 | 60 | org.apache.maven.plugins 61 | maven-jar-plugin 62 | 63 | 64 | 65 | JPMML-XGBoost library 66 | ${project.version} 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /pmml-xgboost-example/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.jpmml 7 | jpmml-xgboost 8 | 1.9-SNAPSHOT 9 | 10 | 11 | org.jpmml 12 | pmml-xgboost-example 13 | jar 14 | 15 | JPMML XGBoost converter example applications 16 | JPMML XGBoost to PMML converter example command-line applications 17 | 18 | 19 | 20 | GNU Affero General Public License (AGPL) version 3.0 21 | http://www.gnu.org/licenses/agpl-3.0.html 22 | repo 23 | 24 | 25 | 26 | 27 | 28 | org.jpmml 29 | pmml-xgboost 30 | 31 | 32 | 33 | com.beust 34 | jcommander 35 | 36 | 37 | 38 | 39 | 40 | 41 | org.apache.maven.plugins 42 | maven-shade-plugin 43 | 44 | 45 | package 46 | 47 | shade 48 | 49 | 50 | ${project.artifactId}-executable-${project.version} 51 | 52 | 53 | 54 | org.jpmml.xgboost.example.Main 55 | JPMML-XGBoost command-line application 56 | ${project.version} 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/BinaryNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import java.io.IOException; 22 | import java.util.BitSet; 23 | 24 | public class BinaryNode extends Node implements BinaryLoadable { 25 | 26 | private int parent; 27 | 28 | private int cleft; 29 | 30 | private int cright; 31 | 32 | private int sindex; 33 | 34 | private int info; 35 | 36 | 37 | public BinaryNode(){ 38 | } 39 | 40 | @Override 41 | public void loadBinary(XGBoostDataInput input) throws IOException { 42 | this.parent = input.readInt(); 43 | this.cleft = input.readInt(); 44 | this.cright = input.readInt(); 45 | this.sindex = input.readInt(); 46 | this.info = input.readInt(); 47 | } 48 | 49 | @Override 50 | public boolean is_leaf(){ 51 | return (this.cleft == -1); 52 | } 53 | 54 | @Override 55 | public float leaf_value(){ 56 | return Float.intBitsToFloat(this.info); 57 | } 58 | 59 | @Override 60 | public int left_child(){ 61 | return this.cleft; 62 | } 63 | 64 | @Override 65 | public int right_child(){ 66 | return this.cright; 67 | } 68 | 69 | @Override 70 | public boolean default_left(){ 71 | return (this.sindex >> 31) != 0; 72 | } 73 | 74 | @Override 75 | public int split_index(){ 76 | return (int)(this.sindex & ((1L << 31) - 1L)); 77 | } 78 | 79 | @Override 80 | public int split_type(){ 81 | return Node.SPLIT_NUMERICAL; 82 | } 83 | 84 | @Override 85 | public int split_cond(){ 86 | return this.info; 87 | } 88 | 89 | @Override 90 | public BitSet get_split_categories(){ 91 | return null; 92 | } 93 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/test/java/org/jpmml/xgboost/testing/MultiRegressionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost.testing; 20 | 21 | import java.util.function.Predicate; 22 | 23 | import com.google.common.base.Equivalence; 24 | import org.jpmml.evaluator.ResultField; 25 | import org.jpmml.evaluator.testing.FloatEquivalence; 26 | import org.junit.jupiter.api.Test; 27 | 28 | public class MultiRegressionTest extends XGBoostEncoderBatchTest implements XGBoostAlgorithms, XGBoostDatasets, XGBoostFormats { 29 | 30 | public MultiRegressionTest(){ 31 | super(new FloatEquivalence(4)); 32 | } 33 | 34 | @Override 35 | public XGBoostEncoderBatch createBatch(String algorithm, String dataset, Predicate columnFilter, Equivalence equivalence){ 36 | XGBoostEncoderBatch result = new XGBoostEncoderBatch(algorithm, dataset, columnFilter, equivalence){ 37 | 38 | { 39 | setFormats(new String[]{JSON, UBJSON}); 40 | } 41 | 42 | @Override 43 | public MultiRegressionTest getArchiveBatchTest(){ 44 | return MultiRegressionTest.this; 45 | } 46 | 47 | @Override 48 | public String getFeatureMapPath(){ 49 | return "/csv/Multi" + truncate(getDataset()) + ".fmap"; 50 | } 51 | }; 52 | 53 | return result; 54 | } 55 | 56 | @Test 57 | public void evaluateMultiLinearAuto() throws Exception { 58 | evaluate("Multi" + LINEAR_REGRESSION, AUTO, new FloatEquivalence(8 + 2)); 59 | } 60 | 61 | @Test 62 | public void evaluateMultiLinearAutoNA() throws Exception { 63 | evaluate("Multi" + LINEAR_REGRESSION, AUTO_NA, new FloatEquivalence(8)); 64 | } 65 | 66 | @Test 67 | public void evaluateMultiRFAuto() throws Exception { 68 | evaluate("Multi" + RANDOM_FOREST, AUTO, new FloatEquivalence(8 + 4)); 69 | } 70 | 71 | @Test 72 | public void evaluateMultiRFAutoNA() throws Exception { 73 | evaluate("Multi" + RANDOM_FOREST, AUTO_NA, new FloatEquivalence(8 + 4)); 74 | } 75 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/HingeClassification.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import java.util.List; 22 | 23 | import org.dmg.pmml.DataType; 24 | import org.dmg.pmml.Expression; 25 | import org.dmg.pmml.FieldRef; 26 | import org.dmg.pmml.OpType; 27 | import org.dmg.pmml.PMMLFunctions; 28 | import org.dmg.pmml.mining.MiningModel; 29 | import org.dmg.pmml.regression.RegressionModel; 30 | import org.jpmml.converter.ExpressionUtil; 31 | import org.jpmml.converter.FieldNameUtil; 32 | import org.jpmml.converter.ModelUtil; 33 | import org.jpmml.converter.Schema; 34 | import org.jpmml.converter.Transformation; 35 | import org.jpmml.converter.mining.MiningModelUtil; 36 | import org.jpmml.converter.transformations.AbstractTransformation; 37 | 38 | public class HingeClassification extends Classification { 39 | 40 | public HingeClassification(String name){ 41 | super(name, 2); 42 | } 43 | 44 | @Override 45 | public MiningModel encodeModel(List trees, List weights, float[] base_score, Integer ntreeLimit, Schema schema){ 46 | Schema segmentSchema = schema.toAnonymousRegressorSchema(DataType.FLOAT); 47 | 48 | Transformation transformation = new AbstractTransformation(){ 49 | 50 | @Override 51 | public String getName(String name){ 52 | return FieldNameUtil.create("hinge", name); 53 | } 54 | 55 | @Override 56 | public Expression createExpression(FieldRef fieldRef){ 57 | return ExpressionUtil.createApply(PMMLFunctions.THRESHOLD, fieldRef, ExpressionUtil.createConstant(0f)); 58 | } 59 | }; 60 | 61 | MiningModel miningModel = createMiningModel(trees, weights, base_score, ntreeLimit, segmentSchema) 62 | .setOutput(ModelUtil.createPredictedOutput("xgbValue", OpType.CONTINUOUS, DataType.FLOAT, transformation)); 63 | 64 | return MiningModelUtil.createBinaryLogisticClassification(miningModel, 1d, 0d, RegressionModel.NormalizationMethod.NONE, true, schema); 65 | } 66 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/MultinomialLogisticRegression.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import java.util.ArrayList; 22 | import java.util.List; 23 | 24 | import org.dmg.pmml.DataType; 25 | import org.dmg.pmml.OpType; 26 | import org.dmg.pmml.mining.MiningModel; 27 | import org.dmg.pmml.regression.RegressionModel; 28 | import org.jpmml.converter.CMatrixUtil; 29 | import org.jpmml.converter.CategoricalLabel; 30 | import org.jpmml.converter.FieldNameUtil; 31 | import org.jpmml.converter.ModelUtil; 32 | import org.jpmml.converter.Schema; 33 | import org.jpmml.converter.mining.MiningModelUtil; 34 | 35 | public class MultinomialLogisticRegression extends Classification { 36 | 37 | public MultinomialLogisticRegression(String name, int num_class){ 38 | super(name, num_class); 39 | 40 | if(num_class < 2){ 41 | throw new IllegalArgumentException("Multi-class classification requires two or more target categories"); 42 | } 43 | } 44 | 45 | @Override 46 | public MiningModel encodeModel(List trees, List weights, float[] base_score, Integer ntreeLimit, Schema schema){ 47 | Schema segmentSchema = schema.toAnonymousRegressorSchema(DataType.FLOAT); 48 | 49 | List miningModels = new ArrayList<>(); 50 | 51 | CategoricalLabel categoricalLabel = (CategoricalLabel)schema.getLabel(); 52 | 53 | for(int i = 0, columns = categoricalLabel.size(), rows = (trees.size() / columns); i < columns; i++){ 54 | MiningModel miningModel = createMiningModel(CMatrixUtil.getColumn(trees, rows, columns, i), (weights != null) ? CMatrixUtil.getColumn(weights, rows, columns, i) : null, targetBaseScore(i, base_score), ntreeLimit, segmentSchema) 55 | .setOutput(ModelUtil.createPredictedOutput(FieldNameUtil.create("xgbValue", categoricalLabel.getValue(i)), OpType.CONTINUOUS, DataType.FLOAT)); 56 | 57 | miningModels.add(miningModel); 58 | } 59 | 60 | return MiningModelUtil.createClassification(miningModels, RegressionModel.NormalizationMethod.SOFTMAX, true, schema); 61 | } 62 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/UBJSONUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import com.devsmart.ubjson.UBArray; 22 | import com.devsmart.ubjson.UBValue; 23 | 24 | public class UBJSONUtil { 25 | 26 | private UBJSONUtil(){ 27 | } 28 | 29 | static 30 | public boolean[] toBooleanArray(UBValue value){ 31 | UBArray array = value.asArray(); 32 | 33 | if(array.isBool()){ 34 | return array.asBoolArray(); 35 | } 36 | 37 | boolean[] result = new boolean[array.size()]; 38 | 39 | for(int i = 0; i < result.length; i++){ 40 | UBValue element = array.get(i); 41 | 42 | if(element.isBool()){ 43 | result[i] = element.asBool(); 44 | } else 45 | 46 | if(element.isNumber()){ 47 | result[i] = (element.asInt() == 1); 48 | } else 49 | 50 | { 51 | throw new IllegalArgumentException(); 52 | } 53 | } 54 | 55 | return result; 56 | } 57 | 58 | static 59 | public int[] toIntArray(UBValue value){ 60 | UBArray array = value.asArray(); 61 | 62 | if(array.isInteger()){ 63 | return array.asInt32Array(); 64 | } 65 | 66 | int[] result = new int[array.size()]; 67 | 68 | for(int i = 0; i < result.length; i++){ 69 | UBValue element = array.get(i); 70 | 71 | result[i] = element.asInt(); 72 | } 73 | 74 | return result; 75 | } 76 | 77 | static 78 | public float[] toFloatArray(UBValue value){ 79 | UBArray array = value.asArray(); 80 | 81 | if(array.isNumber()){ 82 | return array.asFloat32Array(); 83 | } 84 | 85 | float[] result = new float[array.size()]; 86 | 87 | for(int i = 0; i < result.length; i++){ 88 | UBValue element = array.get(i); 89 | 90 | result[i] = element.asFloat32(); 91 | } 92 | 93 | return result; 94 | } 95 | 96 | static 97 | public String[] toStringArray(UBValue value){ 98 | UBArray array = value.asArray(); 99 | 100 | if(array.isString()){ 101 | return array.asStringArray(); 102 | } 103 | 104 | String[] result = new String[array.size()]; 105 | 106 | for(int i = 0; i < result.length; i++){ 107 | UBValue element = array.get(i); 108 | 109 | result[i] = element.asString(); 110 | } 111 | 112 | return result; 113 | } 114 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/JSONNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import java.util.BitSet; 22 | 23 | import com.devsmart.ubjson.GsonUtil; 24 | import com.devsmart.ubjson.UBObject; 25 | import com.devsmart.ubjson.UBValue; 26 | import com.google.gson.JsonObject; 27 | 28 | public class JSONNode extends Node implements JSONLoadable, UBJSONLoadable { 29 | 30 | private int parent; 31 | 32 | private int left_child; 33 | 34 | private int right_child; 35 | 36 | private boolean default_left; 37 | 38 | private int split_index; 39 | 40 | private int split_type; 41 | 42 | private float split_condition; 43 | 44 | private BitSet split_categories; 45 | 46 | 47 | public JSONNode(){ 48 | } 49 | 50 | @Override 51 | public void loadJSON(JsonObject node){ 52 | UBValue value = GsonUtil.toUBValue(node); 53 | 54 | loadUBJSON(value.asObject()); 55 | } 56 | 57 | @Override 58 | public void loadUBJSON(UBObject node){ 59 | this.parent = node.get("parent").asInt(); 60 | this.left_child = node.get("left_child").asInt(); 61 | this.right_child = node.get("right_child").asInt(); 62 | this.default_left = node.get("default_left").asBool(); 63 | this.split_index = node.get("split_index").asInt(); 64 | this.split_type = node.get("split_type").asInt(); 65 | this.split_condition = node.get("split_condition").asFloat32(); 66 | 67 | switch(this.split_type){ 68 | case Node.SPLIT_NUMERICAL: 69 | case Node.SPLIT_CATEGORICAL: 70 | break; 71 | default: 72 | throw new IllegalArgumentException(); 73 | } 74 | } 75 | 76 | @Override 77 | public boolean is_leaf(){ 78 | return (this.left_child == -1); 79 | } 80 | 81 | @Override 82 | public float leaf_value(){ 83 | return this.split_condition; 84 | } 85 | 86 | @Override 87 | public int left_child(){ 88 | return this.left_child; 89 | } 90 | 91 | @Override 92 | public int right_child(){ 93 | return this.right_child; 94 | } 95 | 96 | @Override 97 | public boolean default_left(){ 98 | return this.default_left; 99 | } 100 | 101 | @Override 102 | public int split_index(){ 103 | return this.split_index; 104 | } 105 | 106 | @Override 107 | public int split_type(){ 108 | return this.split_type; 109 | } 110 | 111 | @Override 112 | public int split_cond(){ 113 | return Float.floatToIntBits(this.split_condition); 114 | } 115 | 116 | @Override 117 | public BitSet get_split_categories(){ 118 | return this.split_categories; 119 | } 120 | 121 | void set_split_categories(BitSet split_categories){ 122 | this.split_categories = split_categories; 123 | } 124 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/csv/AFTLungNA.csv: -------------------------------------------------------------------------------- 1 | _target 2 | 132.56462 3 | 265.32437 4 | 390.83652 5 | 245.45549 6 | 417.46478 7 | 230.5399 8 | 200.87674 9 | 288.1933 10 | 279.83606 11 | 170.54936 12 | 279.83606 13 | 392.4577 14 | 496.51584 15 | 294.67035 16 | 364.76083 17 | 272.00388 18 | 367.34888 19 | 238.00597 20 | 110.23651 21 | 151.7126 22 | 253.52898 23 | 342.90335 24 | 300.228 25 | 412.70114 26 | 258.84702 27 | 416.2076 28 | 527.8357 29 | 153.98221 30 | 313.9322 31 | 40.178448 32 | 462.79172 33 | 111.26683 34 | 265.8815 35 | 141.79791 36 | 85.64285 37 | 157.22385 38 | 266.96872 39 | 462.79172 40 | 146.36745 41 | 446.20718 42 | 222.3805 43 | 236.66187 44 | 402.45178 45 | 168.68091 46 | 237.5316 47 | 155.98479 48 | 234.64609 49 | 222.3805 50 | 258.84702 51 | 476.6079 52 | 496.51584 53 | 331.7515 54 | 321.0627 55 | 389.10995 56 | 300.228 57 | 178.93262 58 | 124.60973 59 | 182.34512 60 | 354.21988 61 | 378.3534 62 | 252.78598 63 | 244.85884 64 | 132.56462 65 | 378.3534 66 | 237.5316 67 | 118.8114 68 | 252.78598 69 | 432.0268 70 | 283.4013 71 | 287.22064 72 | 352.53015 73 | 441.79526 74 | 77.87711 75 | 320.68295 76 | 378.3534 77 | 433.27225 78 | 528.432 79 | 331.86905 80 | 20.55767 81 | 138.61916 82 | 389.10995 83 | 300.228 84 | 320.68295 85 | 420.70068 86 | 298.9017 87 | 253.52898 88 | 378.3534 89 | 352.53015 90 | 466.3176 91 | 140.01967 92 | 352.53015 93 | 287.22064 94 | 270.80228 95 | 159.20305 96 | 486.4721 97 | 59.409325 98 | 272.00388 99 | 306.7894 100 | 306.7894 101 | 383.75272 102 | 580.8721 103 | 462.79172 104 | 320.68295 105 | 254.84077 106 | 228.37408 107 | 253.52898 108 | 476.6079 109 | 137.45026 110 | 298.9017 111 | 236.66187 112 | 232.72672 113 | 298.9017 114 | 261.1765 115 | 548.6851 116 | 446.20718 117 | 131.08842 118 | 169.95996 119 | 286.423 120 | 238.00597 121 | 183.19887 122 | 258.84702 123 | 245.27135 124 | 416.2076 125 | 140.01967 126 | 265.32437 127 | 253.52898 128 | 245.45549 129 | 270.80228 130 | 410.31546 131 | 463.50903 132 | 349.143 133 | 300.228 134 | 389.10995 135 | 616.67444 136 | 97.53406 137 | 442.8775 138 | 356.05267 139 | 156.49048 140 | 357.90414 141 | 412.70114 142 | 155.98479 143 | 350.23285 144 | 150.22305 145 | 420.70068 146 | 355.60202 147 | 451.35757 148 | 283.4013 149 | 279.83606 150 | 72.82889 151 | 587.57684 152 | 237.5316 153 | 440.81906 154 | 587.57684 155 | 356.05267 156 | 122.774864 157 | 175.55026 158 | 496.51584 159 | 238.00597 160 | 237.5316 161 | 393.86603 162 | 547.6678 163 | 476.6079 164 | 286.423 165 | 270.80228 166 | 222.3805 167 | 547.6678 168 | 442.82828 169 | 440.81906 170 | 270.80228 171 | 283.4013 172 | 306.7894 173 | 461.1231 174 | 326.0758 175 | 172.35423 176 | 279.83606 177 | 476.6079 178 | 206.96754 179 | 201.57018 180 | 393.86603 181 | 548.6851 182 | 440.81906 183 | 465.9193 184 | 221.04346 185 | 451.35757 186 | 492.5401 187 | 620.44775 188 | 300.00934 189 | 417.46478 190 | 222.3805 191 | 389.10995 192 | 215.83476 193 | 156.49048 194 | 151.7126 195 | 284.3807 196 | 290.53592 197 | 321.0627 198 | 420.70068 199 | 290.53592 200 | 492.5401 201 | 262.17874 202 | 372.33752 203 | 216.95152 204 | 620.44775 205 | 620.44775 206 | 547.6678 207 | 152.11057 208 | 550.0979 209 | 229.79501 210 | 181.76895 211 | 380.03226 212 | 547.6678 213 | 263.37222 214 | 237.5316 215 | 194.77283 216 | 272.00388 217 | 222.3805 218 | 322.18564 219 | 140.01967 220 | 272.8467 221 | 461.1231 222 | 290.53592 223 | 462.79172 224 | 247.33958 225 | 216.95152 226 | 499.8713 227 | 252.78598 228 | 306.7894 229 | 420.70068 230 | -------------------------------------------------------------------------------- /pmml-xgboost/src/test/java/org/jpmml/xgboost/testing/MultiClassificationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost.testing; 20 | 21 | import java.util.function.Predicate; 22 | 23 | import com.google.common.base.Equivalence; 24 | import org.jpmml.converter.FieldNameUtil; 25 | import org.jpmml.converter.FieldNames; 26 | import org.jpmml.converter.testing.Fields; 27 | import org.jpmml.evaluator.ResultField; 28 | import org.jpmml.evaluator.testing.FloatEquivalence; 29 | import org.junit.jupiter.api.Test; 30 | 31 | public class MultiClassificationTest extends XGBoostEncoderBatchTest implements XGBoostAlgorithms, XGBoostDatasets, XGBoostFormats, Fields { 32 | 33 | public MultiClassificationTest(){ 34 | super(new FloatEquivalence(4)); 35 | } 36 | 37 | @Override 38 | public XGBoostEncoderBatch createBatch(String algorithm, String dataset, Predicate columnFilter, Equivalence equivalence){ 39 | XGBoostEncoderBatch result = new XGBoostEncoderBatch(algorithm, dataset, columnFilter, equivalence){ 40 | 41 | { 42 | setFormats(new String[]{JSON, UBJSON}); 43 | } 44 | 45 | @Override 46 | public MultiClassificationTest getArchiveBatchTest(){ 47 | return MultiClassificationTest.this; 48 | } 49 | 50 | @Override 51 | public String getFeatureMapPath(){ 52 | return "/csv/Multi" + truncate(getDataset()) + ".fmap"; 53 | } 54 | }; 55 | 56 | return result; 57 | } 58 | 59 | @Test 60 | public void evaluateMultiBinomialAudit() throws Exception { 61 | evaluate("Multi" + BINOMIAL_CLASSIFICATION, AUDIT, excludeFields(AUDIT_GENDER_PROBABILITY_FALSE, AUDIT_ADJUSTED_PROBABILITY_FALSE), new FloatEquivalence(24 + 32)); 62 | } 63 | 64 | @Test 65 | public void evaluateMultiBinomialAuditLimit() throws Exception { 66 | evaluate("Multi" + BINOMIAL_CLASSIFICATION, AUDIT_LIMIT, excludeFields(AUDIT_GENDER_PROBABILITY_FALSE, AUDIT_ADJUSTED_PROBABILITY_FALSE), new FloatEquivalence(20 + 8)); 67 | } 68 | 69 | @Test 70 | public void evaluateMultiBinomialAuditNA() throws Exception { 71 | evaluate("Multi" + BINOMIAL_CLASSIFICATION, AUDIT_NA, excludeFields(AUDIT_GENDER_PROBABILITY_FALSE, AUDIT_ADJUSTED_PROBABILITY_FALSE), new FloatEquivalence(24 + 32)); 72 | } 73 | 74 | @Test 75 | public void evaluateBinomialAuditNALimit() throws Exception { 76 | evaluate("Multi" + BINOMIAL_CLASSIFICATION, AUDIT_NA_LIMIT, excludeFields(AUDIT_GENDER_PROBABILITY_FALSE, AUDIT_ADJUSTED_PROBABILITY_FALSE), new FloatEquivalence(20 + 8)); 77 | } 78 | 79 | // XXX 80 | private static final String AUDIT_GENDER_PROBABILITY_FALSE = FieldNameUtil.create(FieldNames.PROBABILITY, "_target1", 0); 81 | private static final String AUDIT_ADJUSTED_PROBABILITY_FALSE = FieldNameUtil.create(FieldNames.PROBABILITY, "_target2", 0); 82 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/test/java/org/jpmml/xgboost/testing/RegressionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost.testing; 20 | 21 | import java.util.function.Predicate; 22 | 23 | import com.google.common.base.Equivalence; 24 | import org.jpmml.evaluator.ResultField; 25 | import org.jpmml.evaluator.testing.FloatEquivalence; 26 | import org.junit.jupiter.api.Test; 27 | 28 | public class RegressionTest extends XGBoostEncoderBatchTest implements XGBoostAlgorithms, XGBoostDatasets, XGBoostFormats { 29 | 30 | public RegressionTest(){ 31 | super(new FloatEquivalence(4)); 32 | } 33 | 34 | @Override 35 | public XGBoostEncoderBatch createBatch(String algorithm, String dataset, Predicate columnFilter, Equivalence equivalence){ 36 | XGBoostEncoderBatch result = new XGBoostEncoderBatch(algorithm, dataset, columnFilter, equivalence){ 37 | 38 | { 39 | String dataset = getDataset(); 40 | 41 | // XXX 42 | if(dataset.startsWith(AUDIT) || dataset.startsWith(AUTO) || dataset.startsWith(VISIT)){ 43 | setFormats(new String[]{JSON, UBJSON}); 44 | } 45 | } 46 | 47 | @Override 48 | public RegressionTest getArchiveBatchTest(){ 49 | return RegressionTest.this; 50 | } 51 | }; 52 | 53 | return result; 54 | } 55 | 56 | @Test 57 | public void evaluateLinearAuto() throws Exception { 58 | evaluate(LINEAR_REGRESSION, AUTO, new FloatEquivalence(8)); 59 | } 60 | 61 | @Test 62 | public void evaluateLinearAutoNA() throws Exception { 63 | evaluate(LINEAR_REGRESSION, AUTO_NA, new FloatEquivalence(8 + 2)); 64 | } 65 | 66 | @Test 67 | public void evaluateLogisticAudit() throws Exception { 68 | evaluate(LOGISTIC_REGRESSION, AUDIT, new FloatEquivalence(20 + 8)); 69 | } 70 | 71 | @Test 72 | public void evaluateLogisticAuditNA() throws Exception { 73 | evaluate(LOGISTIC_REGRESSION, AUDIT_NA, new FloatEquivalence(24)); 74 | } 75 | 76 | @Test 77 | public void evaluateAFTLungNA() throws Exception { 78 | evaluate(AFT, LUNG_NA, new FloatEquivalence(20)); 79 | } 80 | 81 | @Test 82 | public void evaluateGammaVisit() throws Exception { 83 | evaluate(GAMMA_REGRESSION, VISIT, new FloatEquivalence(16 + 4)); 84 | } 85 | 86 | @Test 87 | public void evaluateGammaVisitNA() throws Exception { 88 | evaluate(GAMMA_REGRESSION, VISIT_NA, new FloatEquivalence(20)); 89 | } 90 | 91 | @Test 92 | public void evaluatePoissonVisit() throws Exception { 93 | evaluate(POISSON_REGRESSION, VISIT, new FloatEquivalence(20)); 94 | } 95 | 96 | @Test 97 | public void evaluatePoissonVisitNA() throws Exception { 98 | evaluate(POISSON_REGRESSION, VISIT_NA, new FloatEquivalence(16 + 4)); 99 | } 100 | 101 | @Test 102 | public void evaluateTweedieVisit() throws Exception { 103 | evaluate(TWEEDIE_REGRESSION, VISIT, new FloatEquivalence(16)); 104 | } 105 | 106 | @Test 107 | public void evaluateTweedieVisitNA() throws Exception { 108 | evaluate(TWEEDIE_REGRESSION, VISIT_NA, new FloatEquivalence(20)); 109 | } 110 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/Classification.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import java.util.List; 22 | 23 | import org.dmg.pmml.DataField; 24 | import org.dmg.pmml.DataType; 25 | import org.dmg.pmml.Model; 26 | import org.dmg.pmml.OpType; 27 | import org.dmg.pmml.Output; 28 | import org.dmg.pmml.OutputField; 29 | import org.dmg.pmml.ResultFeature; 30 | import org.dmg.pmml.mining.MiningModel; 31 | import org.jpmml.converter.CategoricalLabel; 32 | import org.jpmml.converter.FieldNameUtil; 33 | import org.jpmml.converter.FieldNames; 34 | import org.jpmml.converter.Label; 35 | import org.jpmml.converter.LabelUtil; 36 | import org.jpmml.converter.ModelEncoder; 37 | import org.jpmml.converter.ModelUtil; 38 | import org.jpmml.converter.Schema; 39 | import org.jpmml.converter.mining.MiningModelUtil; 40 | 41 | abstract 42 | public class Classification extends ObjFunction { 43 | 44 | private int num_class; 45 | 46 | 47 | public Classification(String name, int num_class){ 48 | super(name); 49 | 50 | this.num_class = num_class; 51 | } 52 | 53 | @Override 54 | public Label encodeLabel(String targetName, List targetCategories, ModelEncoder encoder){ 55 | DataField dataField; 56 | 57 | if(targetCategories == null){ 58 | targetCategories = LabelUtil.createTargetCategories(this.num_class); 59 | 60 | dataField = encoder.createDataField(targetName, OpType.CATEGORICAL, DataType.INTEGER, targetCategories); 61 | } else 62 | 63 | { 64 | if(targetCategories.size() != this.num_class){ 65 | throw new IllegalArgumentException("Expected " + this.num_class + " target categories, got " + targetCategories.size() + " target categories"); 66 | } 67 | 68 | dataField = encoder.createDataField(targetName, OpType.CATEGORICAL, DataType.STRING, targetCategories); 69 | } 70 | 71 | return new CategoricalLabel(dataField); 72 | } 73 | 74 | @Override 75 | public MiningModel encodeModel(int targetIndex, List trees, List weights, float[] base_score, Integer ntreeLimit, Schema schema){ 76 | MiningModel miningModel = encodeModel(trees, weights, targetBaseScore(targetIndex, base_score), ntreeLimit, schema); 77 | 78 | if(targetIndex != ObjFunction.DEFAULT_TARGET_INDEX){ 79 | Model finalModel = MiningModelUtil.getFinalModel(miningModel); 80 | 81 | Output output = finalModel.getOutput(); 82 | if(output == null || !output.hasOutputFields()){ 83 | throw new IllegalArgumentException(); 84 | } 85 | 86 | List outputFields = output.getOutputFields(); 87 | 88 | outputFields.removeIf((outputField) -> { 89 | return (outputField.getResultFeature() == ResultFeature.PROBABILITY); 90 | }); 91 | 92 | CategoricalLabel categoricalLabel = (CategoricalLabel)schema.getLabel(); 93 | 94 | List values = categoricalLabel.getValues(); 95 | 96 | values.stream() 97 | .map(value -> { 98 | return ModelUtil.createProbabilityField(FieldNameUtil.create(FieldNames.PROBABILITY, categoricalLabel.getName(), value), DataType.FLOAT, value); 99 | }) 100 | .forEach(outputFields::add); 101 | } 102 | 103 | return miningModel; 104 | } 105 | 106 | public int num_class(){ 107 | return this.num_class; 108 | } 109 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/visitors/TreeModelCompactor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost.visitors; 20 | 21 | import java.util.List; 22 | 23 | import org.dmg.pmml.Predicate; 24 | import org.dmg.pmml.True; 25 | import org.dmg.pmml.tree.Node; 26 | import org.dmg.pmml.tree.TreeModel; 27 | import org.jpmml.converter.visitors.AbstractTreeModelTransformer; 28 | import org.jpmml.model.UnsupportedAttributeException; 29 | import org.jpmml.model.UnsupportedElementException; 30 | 31 | public class TreeModelCompactor extends AbstractTreeModelTransformer { 32 | 33 | @Override 34 | public void enterNode(Node node){ 35 | Object id = node.getId(); 36 | Object score = node.getScore(); 37 | Object defaultChild = node.getDefaultChild(); 38 | 39 | if(id == null){ 40 | throw new UnsupportedElementException(node); 41 | } // End if 42 | 43 | if(node.hasNodes()){ 44 | List children = node.getNodes(); 45 | 46 | if(score != null || defaultChild == null || children.size() != 2){ 47 | throw new UnsupportedElementException(node); 48 | } 49 | 50 | Node firstChild = children.get(0); 51 | Node secondChild = children.get(1); 52 | 53 | if(equalsNode(defaultChild, firstChild)){ 54 | children = swapChildren(node); 55 | 56 | firstChild = children.get(0); 57 | secondChild = children.get(1); 58 | } else 59 | 60 | if(equalsNode(defaultChild, secondChild)){ 61 | // Ignored 62 | } else 63 | 64 | { 65 | throw new UnsupportedElementException(node); 66 | } 67 | 68 | node.setDefaultChild(null); 69 | 70 | secondChild.setPredicate(True.INSTANCE); 71 | } else 72 | 73 | { 74 | if(score == null || defaultChild != null){ 75 | throw new UnsupportedElementException(node); 76 | } 77 | } 78 | 79 | node.setId(null); 80 | } 81 | 82 | @Override 83 | public void exitNode(Node node){ 84 | Predicate predicate = node.requirePredicate(); 85 | 86 | if(predicate instanceof True){ 87 | Node parentNode = getParentNode(); 88 | 89 | if(parentNode == null){ 90 | return; 91 | } 92 | 93 | initScore(parentNode, node); 94 | replaceChildWithGrandchildren(parentNode, node); 95 | } 96 | } 97 | 98 | @Override 99 | public void enterTreeModel(TreeModel treeModel){ 100 | super.enterTreeModel(treeModel); 101 | 102 | TreeModel.MissingValueStrategy missingValueStrategy = treeModel.getMissingValueStrategy(); 103 | if(missingValueStrategy != TreeModel.MissingValueStrategy.DEFAULT_CHILD){ 104 | throw new UnsupportedAttributeException(treeModel, missingValueStrategy); 105 | } 106 | 107 | TreeModel.NoTrueChildStrategy noTrueChildStrategy = treeModel.getNoTrueChildStrategy(); 108 | if(noTrueChildStrategy != TreeModel.NoTrueChildStrategy.RETURN_NULL_PREDICTION){ 109 | throw new UnsupportedAttributeException(treeModel, noTrueChildStrategy); 110 | } 111 | 112 | TreeModel.SplitCharacteristic splitCharacteristic = treeModel.getSplitCharacteristic(); 113 | if(splitCharacteristic != TreeModel.SplitCharacteristic.BINARY_SPLIT){ 114 | throw new UnsupportedAttributeException(treeModel, splitCharacteristic); 115 | } 116 | 117 | treeModel 118 | .setMissingValueStrategy(TreeModel.MissingValueStrategy.NONE) 119 | .setNoTrueChildStrategy(TreeModel.NoTrueChildStrategy.RETURN_LAST_PREDICTION) 120 | .setSplitCharacteristic(TreeModel.SplitCharacteristic.MULTI_SPLIT); 121 | } 122 | 123 | @Override 124 | public void exitTreeModel(TreeModel treeModel){ 125 | super.exitTreeModel(treeModel); 126 | } 127 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/csv/IrisNA.csv: -------------------------------------------------------------------------------- 1 | Sepal.Length,Sepal.Width,Petal.Length,Petal.Width,Species 2 | 5.1,NA,1.4,0.2,setosa 3 | NA,3,1.4,0.2,setosa 4 | 4.7,NA,1.3,0.2,setosa 5 | 4.6,3.1,1.5,0.2,setosa 6 | NA,NA,1.4,0.2,setosa 7 | 5.4,3.9,1.7,NA,setosa 8 | NA,3.4,1.4,0.3,setosa 9 | 5,3.4,1.5,0.2,setosa 10 | NA,NA,1.4,NA,setosa 11 | 4.9,NA,1.5,NA,setosa 12 | 5.4,3.7,1.5,0.2,setosa 13 | NA,3.4,1.6,0.2,setosa 14 | 4.8,NA,1.4,NA,setosa 15 | 4.3,3,1.1,0.1,setosa 16 | NA,4,1.2,NA,setosa 17 | 5.7,4.4,1.5,0.4,setosa 18 | 5.4,3.9,1.3,NA,setosa 19 | 5.1,NA,1.4,0.3,setosa 20 | 5.7,3.8,1.7,0.3,setosa 21 | 5.1,3.8,1.5,0.3,setosa 22 | 5.4,3.4,1.7,0.2,setosa 23 | 5.1,NA,1.5,0.4,setosa 24 | 4.6,3.6,1,0.2,setosa 25 | 5.1,3.3,1.7,0.5,setosa 26 | 4.8,NA,NA,0.2,setosa 27 | 5,NA,1.6,0.2,setosa 28 | 5,3.4,1.6,0.4,setosa 29 | NA,3.5,1.5,0.2,setosa 30 | 5.2,3.4,1.4,0.2,setosa 31 | 4.7,3.2,1.6,NA,setosa 32 | 4.8,NA,1.6,0.2,setosa 33 | 5.4,NA,1.5,NA,setosa 34 | 5.2,4.1,NA,0.1,setosa 35 | 5.5,4.2,NA,0.2,setosa 36 | NA,3.1,1.5,0.2,setosa 37 | NA,NA,NA,NA,setosa 38 | 5.5,3.5,1.3,0.2,setosa 39 | 4.9,NA,1.4,0.1,setosa 40 | 4.4,3,NA,0.2,setosa 41 | 5.1,3.4,1.5,NA,setosa 42 | 5,3.5,NA,0.3,setosa 43 | 4.5,2.3,1.3,0.3,setosa 44 | 4.4,3.2,NA,0.2,setosa 45 | 5,3.5,NA,0.6,setosa 46 | 5.1,NA,1.9,0.4,setosa 47 | 4.8,NA,1.4,0.3,setosa 48 | NA,NA,1.6,NA,setosa 49 | 4.6,NA,1.4,0.2,setosa 50 | 5.3,3.7,1.5,NA,setosa 51 | 5,NA,NA,0.2,setosa 52 | 7,3.2,4.7,1.4,versicolor 53 | 6.4,3.2,4.5,NA,versicolor 54 | NA,3.1,NA,1.5,versicolor 55 | 5.5,2.3,4,1.3,versicolor 56 | 6.5,NA,4.6,NA,versicolor 57 | 5.7,2.8,4.5,NA,versicolor 58 | 6.3,3.3,NA,1.6,versicolor 59 | NA,2.4,NA,1,versicolor 60 | 6.6,NA,4.6,1.3,versicolor 61 | 5.2,2.7,NA,1.4,versicolor 62 | 5,2,NA,1,versicolor 63 | NA,NA,NA,1.5,versicolor 64 | NA,2.2,4,1,versicolor 65 | 6.1,2.9,4.7,NA,versicolor 66 | NA,2.9,3.6,1.3,versicolor 67 | NA,3.1,4.4,1.4,versicolor 68 | 5.6,3,NA,NA,versicolor 69 | 5.8,2.7,4.1,1,versicolor 70 | 6.2,NA,NA,1.5,versicolor 71 | 5.6,NA,NA,1.1,versicolor 72 | 5.9,NA,NA,1.8,versicolor 73 | 6.1,NA,4,1.3,versicolor 74 | 6.3,2.5,4.9,NA,versicolor 75 | 6.1,NA,NA,1.2,versicolor 76 | 6.4,2.9,NA,NA,versicolor 77 | NA,3,NA,1.4,versicolor 78 | 6.8,2.8,4.8,1.4,versicolor 79 | 6.7,3,5,1.7,versicolor 80 | 6,2.9,4.5,NA,versicolor 81 | 5.7,2.6,3.5,1,versicolor 82 | 5.5,NA,3.8,NA,versicolor 83 | 5.5,NA,3.7,1,versicolor 84 | 5.8,2.7,NA,1.2,versicolor 85 | 6,2.7,5.1,1.6,versicolor 86 | 5.4,3,4.5,1.5,versicolor 87 | 6,3.4,NA,NA,versicolor 88 | 6.7,NA,4.7,NA,versicolor 89 | 6.3,2.3,NA,1.3,versicolor 90 | 5.6,3,NA,NA,versicolor 91 | 5.5,2.5,4,1.3,versicolor 92 | 5.5,2.6,4.4,1.2,versicolor 93 | NA,3,4.6,NA,versicolor 94 | 5.8,2.6,4,1.2,versicolor 95 | 5,2.3,3.3,1,versicolor 96 | 5.6,NA,NA,1.3,versicolor 97 | 5.7,3,4.2,1.2,versicolor 98 | 5.7,2.9,NA,1.3,versicolor 99 | NA,NA,NA,1.3,versicolor 100 | 5.1,NA,3,1.1,versicolor 101 | 5.7,NA,4.1,1.3,versicolor 102 | NA,3.3,6,2.5,virginica 103 | NA,NA,5.1,1.9,virginica 104 | NA,3,5.9,2.1,virginica 105 | 6.3,2.9,5.6,NA,virginica 106 | 6.5,3,NA,2.2,virginica 107 | NA,3,6.6,NA,virginica 108 | NA,2.5,4.5,1.7,virginica 109 | 7.3,2.9,6.3,1.8,virginica 110 | 6.7,2.5,5.8,NA,virginica 111 | NA,3.6,6.1,2.5,virginica 112 | 6.5,NA,5.1,2,virginica 113 | 6.4,NA,5.3,1.9,virginica 114 | 6.8,3,5.5,2.1,virginica 115 | NA,2.5,5,NA,virginica 116 | NA,2.8,5.1,NA,virginica 117 | 6.4,NA,5.3,2.3,virginica 118 | 6.5,3,5.5,1.8,virginica 119 | 7.7,3.8,6.7,NA,virginica 120 | 7.7,2.6,6.9,2.3,virginica 121 | NA,2.2,5,1.5,virginica 122 | NA,3.2,NA,NA,virginica 123 | 5.6,NA,NA,2,virginica 124 | 7.7,2.8,6.7,2,virginica 125 | 6.3,NA,4.9,1.8,virginica 126 | 6.7,3.3,5.7,NA,virginica 127 | NA,3.2,6,1.8,virginica 128 | 6.2,NA,NA,NA,virginica 129 | 6.1,3,NA,1.8,virginica 130 | 6.4,2.8,5.6,NA,virginica 131 | 7.2,3,5.8,1.6,virginica 132 | 7.4,2.8,6.1,1.9,virginica 133 | 7.9,NA,6.4,NA,virginica 134 | 6.4,2.8,NA,2.2,virginica 135 | 6.3,NA,5.1,1.5,virginica 136 | 6.1,NA,5.6,1.4,virginica 137 | NA,3,6.1,2.3,virginica 138 | NA,NA,5.6,2.4,virginica 139 | 6.4,3.1,NA,1.8,virginica 140 | 6,3,NA,NA,virginica 141 | 6.9,NA,5.4,2.1,virginica 142 | NA,3.1,5.6,2.4,virginica 143 | NA,NA,NA,2.3,virginica 144 | 5.8,2.7,5.1,1.9,virginica 145 | 6.8,NA,5.9,2.3,virginica 146 | 6.7,3.3,5.7,NA,virginica 147 | 6.7,3,5.2,2.3,virginica 148 | 6.3,NA,5,1.9,virginica 149 | 6.5,3,5.2,NA,virginica 150 | 6.2,NA,5.4,2.3,virginica 151 | 5.9,3,5.1,NA,virginica 152 | -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/csv/Iris.csv: -------------------------------------------------------------------------------- 1 | Sepal.Length,Sepal.Width,Petal.Length,Petal.Width,Species 2 | 5.1,3.5,1.4,0.2,setosa 3 | 4.9,3,1.4,0.2,setosa 4 | 4.7,3.2,1.3,0.2,setosa 5 | 4.6,3.1,1.5,0.2,setosa 6 | 5,3.6,1.4,0.2,setosa 7 | 5.4,3.9,1.7,0.4,setosa 8 | 4.6,3.4,1.4,0.3,setosa 9 | 5,3.4,1.5,0.2,setosa 10 | 4.4,2.9,1.4,0.2,setosa 11 | 4.9,3.1,1.5,0.1,setosa 12 | 5.4,3.7,1.5,0.2,setosa 13 | 4.8,3.4,1.6,0.2,setosa 14 | 4.8,3,1.4,0.1,setosa 15 | 4.3,3,1.1,0.1,setosa 16 | 5.8,4,1.2,0.2,setosa 17 | 5.7,4.4,1.5,0.4,setosa 18 | 5.4,3.9,1.3,0.4,setosa 19 | 5.1,3.5,1.4,0.3,setosa 20 | 5.7,3.8,1.7,0.3,setosa 21 | 5.1,3.8,1.5,0.3,setosa 22 | 5.4,3.4,1.7,0.2,setosa 23 | 5.1,3.7,1.5,0.4,setosa 24 | 4.6,3.6,1,0.2,setosa 25 | 5.1,3.3,1.7,0.5,setosa 26 | 4.8,3.4,1.9,0.2,setosa 27 | 5,3,1.6,0.2,setosa 28 | 5,3.4,1.6,0.4,setosa 29 | 5.2,3.5,1.5,0.2,setosa 30 | 5.2,3.4,1.4,0.2,setosa 31 | 4.7,3.2,1.6,0.2,setosa 32 | 4.8,3.1,1.6,0.2,setosa 33 | 5.4,3.4,1.5,0.4,setosa 34 | 5.2,4.1,1.5,0.1,setosa 35 | 5.5,4.2,1.4,0.2,setosa 36 | 4.9,3.1,1.5,0.2,setosa 37 | 5,3.2,1.2,0.2,setosa 38 | 5.5,3.5,1.3,0.2,setosa 39 | 4.9,3.6,1.4,0.1,setosa 40 | 4.4,3,1.3,0.2,setosa 41 | 5.1,3.4,1.5,0.2,setosa 42 | 5,3.5,1.3,0.3,setosa 43 | 4.5,2.3,1.3,0.3,setosa 44 | 4.4,3.2,1.3,0.2,setosa 45 | 5,3.5,1.6,0.6,setosa 46 | 5.1,3.8,1.9,0.4,setosa 47 | 4.8,3,1.4,0.3,setosa 48 | 5.1,3.8,1.6,0.2,setosa 49 | 4.6,3.2,1.4,0.2,setosa 50 | 5.3,3.7,1.5,0.2,setosa 51 | 5,3.3,1.4,0.2,setosa 52 | 7,3.2,4.7,1.4,versicolor 53 | 6.4,3.2,4.5,1.5,versicolor 54 | 6.9,3.1,4.9,1.5,versicolor 55 | 5.5,2.3,4,1.3,versicolor 56 | 6.5,2.8,4.6,1.5,versicolor 57 | 5.7,2.8,4.5,1.3,versicolor 58 | 6.3,3.3,4.7,1.6,versicolor 59 | 4.9,2.4,3.3,1,versicolor 60 | 6.6,2.9,4.6,1.3,versicolor 61 | 5.2,2.7,3.9,1.4,versicolor 62 | 5,2,3.5,1,versicolor 63 | 5.9,3,4.2,1.5,versicolor 64 | 6,2.2,4,1,versicolor 65 | 6.1,2.9,4.7,1.4,versicolor 66 | 5.6,2.9,3.6,1.3,versicolor 67 | 6.7,3.1,4.4,1.4,versicolor 68 | 5.6,3,4.5,1.5,versicolor 69 | 5.8,2.7,4.1,1,versicolor 70 | 6.2,2.2,4.5,1.5,versicolor 71 | 5.6,2.5,3.9,1.1,versicolor 72 | 5.9,3.2,4.8,1.8,versicolor 73 | 6.1,2.8,4,1.3,versicolor 74 | 6.3,2.5,4.9,1.5,versicolor 75 | 6.1,2.8,4.7,1.2,versicolor 76 | 6.4,2.9,4.3,1.3,versicolor 77 | 6.6,3,4.4,1.4,versicolor 78 | 6.8,2.8,4.8,1.4,versicolor 79 | 6.7,3,5,1.7,versicolor 80 | 6,2.9,4.5,1.5,versicolor 81 | 5.7,2.6,3.5,1,versicolor 82 | 5.5,2.4,3.8,1.1,versicolor 83 | 5.5,2.4,3.7,1,versicolor 84 | 5.8,2.7,3.9,1.2,versicolor 85 | 6,2.7,5.1,1.6,versicolor 86 | 5.4,3,4.5,1.5,versicolor 87 | 6,3.4,4.5,1.6,versicolor 88 | 6.7,3.1,4.7,1.5,versicolor 89 | 6.3,2.3,4.4,1.3,versicolor 90 | 5.6,3,4.1,1.3,versicolor 91 | 5.5,2.5,4,1.3,versicolor 92 | 5.5,2.6,4.4,1.2,versicolor 93 | 6.1,3,4.6,1.4,versicolor 94 | 5.8,2.6,4,1.2,versicolor 95 | 5,2.3,3.3,1,versicolor 96 | 5.6,2.7,4.2,1.3,versicolor 97 | 5.7,3,4.2,1.2,versicolor 98 | 5.7,2.9,4.2,1.3,versicolor 99 | 6.2,2.9,4.3,1.3,versicolor 100 | 5.1,2.5,3,1.1,versicolor 101 | 5.7,2.8,4.1,1.3,versicolor 102 | 6.3,3.3,6,2.5,virginica 103 | 5.8,2.7,5.1,1.9,virginica 104 | 7.1,3,5.9,2.1,virginica 105 | 6.3,2.9,5.6,1.8,virginica 106 | 6.5,3,5.8,2.2,virginica 107 | 7.6,3,6.6,2.1,virginica 108 | 4.9,2.5,4.5,1.7,virginica 109 | 7.3,2.9,6.3,1.8,virginica 110 | 6.7,2.5,5.8,1.8,virginica 111 | 7.2,3.6,6.1,2.5,virginica 112 | 6.5,3.2,5.1,2,virginica 113 | 6.4,2.7,5.3,1.9,virginica 114 | 6.8,3,5.5,2.1,virginica 115 | 5.7,2.5,5,2,virginica 116 | 5.8,2.8,5.1,2.4,virginica 117 | 6.4,3.2,5.3,2.3,virginica 118 | 6.5,3,5.5,1.8,virginica 119 | 7.7,3.8,6.7,2.2,virginica 120 | 7.7,2.6,6.9,2.3,virginica 121 | 6,2.2,5,1.5,virginica 122 | 6.9,3.2,5.7,2.3,virginica 123 | 5.6,2.8,4.9,2,virginica 124 | 7.7,2.8,6.7,2,virginica 125 | 6.3,2.7,4.9,1.8,virginica 126 | 6.7,3.3,5.7,2.1,virginica 127 | 7.2,3.2,6,1.8,virginica 128 | 6.2,2.8,4.8,1.8,virginica 129 | 6.1,3,4.9,1.8,virginica 130 | 6.4,2.8,5.6,2.1,virginica 131 | 7.2,3,5.8,1.6,virginica 132 | 7.4,2.8,6.1,1.9,virginica 133 | 7.9,3.8,6.4,2,virginica 134 | 6.4,2.8,5.6,2.2,virginica 135 | 6.3,2.8,5.1,1.5,virginica 136 | 6.1,2.6,5.6,1.4,virginica 137 | 7.7,3,6.1,2.3,virginica 138 | 6.3,3.4,5.6,2.4,virginica 139 | 6.4,3.1,5.5,1.8,virginica 140 | 6,3,4.8,1.8,virginica 141 | 6.9,3.1,5.4,2.1,virginica 142 | 6.7,3.1,5.6,2.4,virginica 143 | 6.9,3.1,5.1,2.3,virginica 144 | 5.8,2.7,5.1,1.9,virginica 145 | 6.8,3.2,5.9,2.3,virginica 146 | 6.7,3.3,5.7,2.5,virginica 147 | 6.7,3,5.2,2.3,virginica 148 | 6.3,2.5,5,1.9,virginica 149 | 6.5,3,5.2,2,virginica 150 | 6.2,3.4,5.4,2.3,virginica 151 | 5.9,3,5.1,1.8,virginica 152 | -------------------------------------------------------------------------------- /pmml-xgboost/src/test/java/org/jpmml/xgboost/testing/ClassificationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost.testing; 20 | 21 | import java.io.IOException; 22 | import java.util.function.Predicate; 23 | 24 | import com.google.common.base.Equivalence; 25 | import org.jpmml.converter.testing.Fields; 26 | import org.jpmml.evaluator.ResultField; 27 | import org.jpmml.evaluator.Table; 28 | import org.jpmml.evaluator.testing.FloatEquivalence; 29 | import org.junit.jupiter.api.Test; 30 | 31 | public class ClassificationTest extends XGBoostEncoderBatchTest implements XGBoostAlgorithms, XGBoostDatasets, XGBoostFormats, Fields { 32 | 33 | public ClassificationTest(){ 34 | super(new FloatEquivalence(4)); 35 | } 36 | 37 | @Override 38 | public XGBoostEncoderBatch createBatch(String algorithm, String dataset, Predicate columnFilter, Equivalence equivalence){ 39 | XGBoostEncoderBatch result = new XGBoostEncoderBatch(algorithm, dataset, columnFilter, equivalence){ 40 | 41 | { 42 | String dataset = getDataset(); 43 | 44 | // XXX 45 | if(dataset.startsWith(AUDIT)){ 46 | setFormats(new String[]{JSON, UBJSON}); 47 | } 48 | } 49 | 50 | @Override 51 | public ClassificationTest getArchiveBatchTest(){ 52 | return ClassificationTest.this; 53 | } 54 | 55 | @Override 56 | public Table getInput() throws IOException { 57 | Table table = super.getInput(); 58 | 59 | String dataset = truncate(getDataset()); 60 | 61 | // XXX 62 | if((AUDIT_NA).equals(dataset)){ 63 | table.apply("Income", (value) -> { 64 | 65 | if(value == null){ 66 | return "NaN"; 67 | } 68 | 69 | return value; 70 | }); 71 | } 72 | 73 | return table; 74 | } 75 | }; 76 | 77 | return result; 78 | } 79 | 80 | @Test 81 | public void evaluateBinomialAudit() throws Exception { 82 | evaluate(BINOMIAL_CLASSIFICATION, AUDIT, excludeFields(AUDIT_PROBABILITY_FALSE), new FloatEquivalence(40 + 16)); 83 | } 84 | 85 | @Test 86 | public void evaluateBinomialAuditLimit() throws Exception { 87 | evaluate(BINOMIAL_CLASSIFICATION, AUDIT_LIMIT, excludeFields(AUDIT_PROBABILITY_FALSE), new FloatEquivalence(28)); 88 | } 89 | 90 | @Test 91 | public void evaluateBinomialAuditNA() throws Exception { 92 | evaluate(BINOMIAL_CLASSIFICATION, AUDIT_NA, excludeFields(AUDIT_PROBABILITY_FALSE), new FloatEquivalence(40 + 12)); 93 | } 94 | 95 | @Test 96 | public void evaluateBinomialAuditNALimit() throws Exception { 97 | evaluate(BINOMIAL_CLASSIFICATION, AUDIT_NA_LIMIT, excludeFields(AUDIT_PROBABILITY_FALSE), new FloatEquivalence(36)); 98 | } 99 | 100 | @Test 101 | public void evaluateHingeAudit() throws Exception { 102 | evaluate(HINGE_CLASSIFICATION, AUDIT); 103 | } 104 | 105 | @Test 106 | public void evaluateHingeAuditNA() throws Exception { 107 | evaluate(HINGE_CLASSIFICATION, AUDIT_NA); 108 | } 109 | 110 | @Test 111 | public void evaluateMultinomialAudit() throws Exception { 112 | evaluate(MULTINOMIAL_CLASSIFICATION, AUDIT, new FloatEquivalence(20 + 4)); 113 | } 114 | 115 | @Test 116 | public void evaluateMultinomialAuditNA() throws Exception { 117 | evaluate(MULTINOMIAL_CLASSIFICATION, AUDIT_NA, new FloatEquivalence(28)); 118 | } 119 | 120 | @Test 121 | public void evaluateMultinomialIris() throws Exception { 122 | evaluate(MULTINOMIAL_CLASSIFICATION, IRIS, new FloatEquivalence(16)); 123 | } 124 | 125 | @Test 126 | public void evaluateMultinomialIrisLimit() throws Exception { 127 | evaluate(MULTINOMIAL_CLASSIFICATION, IRIS_LIMIT, new FloatEquivalence(8)); 128 | } 129 | 130 | @Test 131 | public void evaluateMultinomialIrisNA() throws Exception { 132 | evaluate(MULTINOMIAL_CLASSIFICATION, IRIS_NA, new FloatEquivalence(20)); 133 | } 134 | 135 | @Test 136 | public void evaluateMultinomialIrisNALimit() throws Exception { 137 | evaluate(MULTINOMIAL_CLASSIFICATION, IRIS_NA_LIMIT, new FloatEquivalence(12)); 138 | } 139 | } -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.jpmml 7 | jpmml-parent 8 | 1.0.10 9 | 10 | 11 | org.jpmml 12 | jpmml-xgboost 13 | 1.9-SNAPSHOT 14 | pom 15 | 16 | JPMML-XGBoost 17 | Java library and command-line application for converting XGBoost models to PMML 18 | https://github.com/jpmml/jpmml-xgboost 19 | 20 | 21 | 22 | GNU Affero General Public License (AGPL) version 3.0 23 | http://www.gnu.org/licenses/agpl-3.0.html 24 | repo 25 | 26 | 27 | 28 | 29 | 30 | villu.ruusmann 31 | Villu Ruusmann 32 | 33 | 34 | 35 | 36 | pmml-xgboost 37 | pmml-xgboost-example 38 | 39 | 40 | 41 | scm:git:git@github.com:jpmml/jpmml-xgboost.git 42 | scm:git:git@github.com:jpmml/jpmml-xgboost.git 43 | git://github.com/jpmml/jpmml-xgboost.git 44 | HEAD 45 | 46 | 47 | GitHub 48 | https://github.com/jpmml/jpmml-xgboost/issues 49 | 50 | 51 | 52 | 1.6.4 53 | 1.7.5 54 | [2.8.1, 2.13.2] 55 | 0.1.8 56 | 2025-10-23T08:18:35Z 57 | 58 | 59 | 60 | 61 | 62 | org.jpmml 63 | pmml-xgboost 64 | 1.9-SNAPSHOT 65 | 66 | 67 | org.jpmml 68 | pmml-xgboost-example 69 | 1.9-SNAPSHOT 70 | 71 | 72 | 73 | org.jpmml 74 | pmml-converter 75 | ${jpmml-converter.version} 76 | 77 | 78 | org.jpmml 79 | pmml-converter-testing 80 | ${jpmml-converter.version} 81 | 82 | 83 | 84 | org.jpmml 85 | pmml-evaluator-testing 86 | ${jpmml-evaluator.version} 87 | 88 | 89 | 90 | com.beust 91 | jcommander 92 | 1.82 93 | 94 | 95 | 96 | com.dev-smart 97 | ubjson 98 | ${ubjson.version} 99 | 100 | 101 | com.dev-smart 102 | ubjson-gson 103 | ${ubjson.version} 104 | 105 | 106 | 107 | com.google.code.gson 108 | gson 109 | ${gson.version} 110 | 111 | 112 | com.google.errorprone 113 | error_prone_annotations 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | de.jutzig 124 | github-release-plugin 125 | 1.2.0 126 | 127 | 128 | default-cli 129 | 130 | ${project.build.directory}/${project.artifactId}-executable-${project.version}.${project.packaging} 131 | https://github.com/jpmml/jpmml-xgboost 132 | ${project.version} 133 | jpmml/jpmml-xgboost 134 | ${project.version} 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/XGBoostUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import java.io.BufferedInputStream; 22 | import java.io.DataInput; 23 | import java.io.DataInputStream; 24 | import java.io.IOException; 25 | import java.io.InputStream; 26 | import java.io.InputStreamReader; 27 | import java.io.Reader; 28 | import java.nio.ByteOrder; 29 | import java.util.Iterator; 30 | import java.util.List; 31 | import java.util.StringTokenizer; 32 | 33 | import com.google.common.io.CharStreams; 34 | import com.google.common.io.LittleEndianDataInputStream; 35 | 36 | public class XGBoostUtil { 37 | 38 | private XGBoostUtil(){ 39 | } 40 | 41 | static 42 | public Learner loadLearner(InputStream is) throws IOException { 43 | return loadLearner(is, ByteOrder.nativeOrder(), null); 44 | } 45 | 46 | static 47 | public Learner loadLearner(InputStream is, ByteOrder byteOrder, String charset) throws IOException { 48 | return loadLearner(is, byteOrder, charset, "$"); 49 | } 50 | 51 | static 52 | public Learner loadLearner(InputStream is, ByteOrder byteOrder, String charset, String jsonPath) throws IOException { 53 | is = new BufferedInputStream(is, 16 * 1024); 54 | 55 | if((ByteOrder.BIG_ENDIAN).equals(byteOrder)){ 56 | return loadLearner(new DataInputStream(is), charset, jsonPath); 57 | } else 58 | 59 | if((ByteOrder.LITTLE_ENDIAN).equals(byteOrder)){ 60 | return loadLearner(new LittleEndianDataInputStream(is), charset, jsonPath); 61 | } else 62 | 63 | { 64 | throw new IllegalArgumentException(); 65 | } 66 | } 67 | 68 | static 69 | public Learner loadLearner(DIS is, String charset, String jsonPath) throws IOException { 70 | 71 | if(!is.markSupported()){ 72 | throw new IllegalArgumentException(); 73 | } 74 | 75 | String signature = readSignature(is, 16); 76 | 77 | Learner learner = new Learner(); 78 | 79 | if(signature.startsWith("{")){ 80 | 81 | if(isText(signature)){ 82 | learner.loadJSON(is, charset, jsonPath); 83 | } else 84 | 85 | { 86 | learner.loadUBJSON(is, jsonPath); 87 | } 88 | } else 89 | 90 | { 91 | learner.loadBinary(is, charset); 92 | } 93 | 94 | return learner; 95 | } 96 | 97 | static 98 | public FeatureMap loadFeatureMap(InputStream is) throws IOException { 99 | FeatureMap featureMap = new FeatureMap(); 100 | 101 | Iterator lines = parseFeatureMap(is); 102 | for(int i = 0; lines.hasNext(); i++){ 103 | String line = lines.next(); 104 | 105 | StringTokenizer st = new StringTokenizer(line, "\t"); 106 | if(st.countTokens() != 3){ 107 | throw new IllegalArgumentException(line); 108 | } 109 | 110 | String id = st.nextToken(); 111 | String name = st.nextToken(); 112 | String type = st.nextToken(); 113 | 114 | if(Integer.parseInt(id) != i){ 115 | throw new IllegalArgumentException(id); 116 | } 117 | 118 | featureMap.addEntry(name, type); 119 | } 120 | 121 | return featureMap; 122 | } 123 | 124 | static 125 | private Iterator parseFeatureMap(InputStream is) throws IOException { 126 | Reader reader = new InputStreamReader(is, "UTF-8"); 127 | 128 | List lines = CharStreams.readLines(reader); 129 | 130 | return lines.iterator(); 131 | } 132 | 133 | static 134 | private String readSignature(InputStream is, int limit) throws IOException { 135 | is.mark(limit); 136 | 137 | try { 138 | byte[] buffer = new byte[limit]; 139 | 140 | int length = is.read(buffer); 141 | 142 | return new String(buffer, 0, length); 143 | } finally { 144 | is.reset(); 145 | } 146 | } 147 | 148 | static 149 | private boolean isText(String json){ 150 | 151 | if(!json.startsWith("{")){ 152 | throw new IllegalArgumentException(); 153 | } 154 | 155 | for(int i = 1; i < json.length(); i++){ 156 | char c = json.charAt(i); 157 | 158 | if(Character.isWhitespace(c)){ 159 | continue; 160 | } // End if 161 | 162 | if(c == '\"'){ 163 | return true; 164 | } else 165 | 166 | { 167 | return false; 168 | } 169 | } 170 | 171 | return true; 172 | } 173 | 174 | public static final String SERIALIZATION_HEADER = "CONFIG-offset:"; 175 | public static final String BINF_HEADER = "binf"; 176 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/XGBoostDataInput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import java.io.Closeable; 22 | import java.io.DataInput; 23 | import java.io.IOException; 24 | import java.io.InputStream; 25 | import java.lang.reflect.Array; 26 | import java.lang.reflect.Constructor; 27 | import java.util.Arrays; 28 | import java.util.LinkedHashMap; 29 | import java.util.Map; 30 | 31 | import com.google.common.io.ByteStreams; 32 | 33 | public class XGBoostDataInput implements Closeable { 34 | 35 | private InputStream is = null; 36 | 37 | private String charset = null; 38 | 39 | 40 | public XGBoostDataInput(InputStream is, String charset){ 41 | this.is = is; 42 | this.charset = charset; 43 | } 44 | 45 | @Override 46 | public void close() throws IOException { 47 | this.is.close(); 48 | } 49 | 50 | public int readInt() throws IOException { 51 | return asDataInput().readInt(); 52 | } 53 | 54 | public int[] readIntVector() throws IOException { 55 | int length = (int)readLong(); 56 | 57 | return readIntArray(length); 58 | } 59 | 60 | public int[] readIntArray(int length) throws IOException { 61 | DataInput dataInput = asDataInput(); 62 | 63 | int[] result = new int[length]; 64 | 65 | for(int i = 0; i < result.length; i++){ 66 | result[i] = dataInput.readInt(); 67 | } 68 | 69 | return result; 70 | } 71 | 72 | public long readLong() throws IOException { 73 | return asDataInput().readLong(); 74 | } 75 | 76 | public float readFloat() throws IOException { 77 | return asDataInput().readFloat(); 78 | } 79 | 80 | public float[] readFloatVector() throws IOException { 81 | int length = (int)readLong(); 82 | 83 | return readFloatArray(length); 84 | } 85 | 86 | public float[] readFloatArray(int length) throws IOException { 87 | DataInput dataInput = asDataInput(); 88 | 89 | float[] result = new float[length]; 90 | 91 | for(int i = 0; i < result.length; i++){ 92 | result[i] = dataInput.readFloat(); 93 | } 94 | 95 | return result; 96 | } 97 | 98 | public String readString() throws IOException { 99 | int length = (int)readLong(); 100 | 101 | byte[] buffer = new byte[length]; 102 | 103 | ByteStreams.readFully(this.is, buffer); 104 | 105 | if(this.charset != null){ 106 | return new String(buffer, this.charset); 107 | } 108 | 109 | return new String(buffer); 110 | } 111 | 112 | public String[] readStringVector() throws IOException { 113 | int length = (int)readLong(); 114 | 115 | return readStringArray(length); 116 | } 117 | 118 | public String[] readStringArray(int length) throws IOException { 119 | String[] result = new String[length]; 120 | 121 | for(int i = 0; i < result.length; i++){ 122 | result[i] = readString(); 123 | } 124 | 125 | return result; 126 | } 127 | 128 | public Map readStringMap() throws IOException { 129 | int length = (int)readLong(); 130 | 131 | Map result = new LinkedHashMap<>(); 132 | 133 | for(int i = 0; i < length; i++){ 134 | result.put(readString(), readString()); 135 | } 136 | 137 | return result; 138 | } 139 | 140 | public E[] readObjectVector(Class clazz) throws IOException { 141 | int length = (int)readLong(); 142 | 143 | return readObjectArray(clazz, length); 144 | } 145 | 146 | @SuppressWarnings("unchecked") 147 | public E[] readObjectArray(Class clazz, int length) throws IOException { 148 | E[] result = (E[])Array.newInstance(clazz, length); 149 | 150 | try { 151 | Constructor constructor = clazz.getDeclaredConstructor(); 152 | 153 | for(int i = 0; i < result.length; i++){ 154 | E object = constructor.newInstance(); 155 | 156 | object.loadBinary(this); 157 | 158 | result[i] = object; 159 | } 160 | } catch(ReflectiveOperationException roe){ 161 | throw new IOException(roe); 162 | } 163 | 164 | return result; 165 | } 166 | 167 | public void readReserved(int length) throws IOException { 168 | int[] buffer = new int[length]; 169 | 170 | boolean empty = true; 171 | 172 | for(int i = 0; i < length; i++){ 173 | int value = readInt(); 174 | 175 | buffer[i] = value; 176 | 177 | empty &= (value == 0); 178 | } 179 | 180 | if(!empty){ 181 | throw new IOException("Expected " + length + "-element array of zeroes, got " + Arrays.toString(buffer)); 182 | } 183 | } 184 | 185 | private DataInput asDataInput(){ 186 | return (DataInput)this.is; 187 | } 188 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/testing/XGBoostEncoderBatch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost.testing; 20 | 21 | import java.io.InputStream; 22 | import java.util.LinkedHashMap; 23 | import java.util.List; 24 | import java.util.Map; 25 | import java.util.Objects; 26 | import java.util.function.Predicate; 27 | 28 | import com.google.common.base.Equivalence; 29 | import org.dmg.pmml.Header; 30 | import org.dmg.pmml.PMML; 31 | import org.dmg.pmml.Timestamp; 32 | import org.jpmml.converter.testing.ModelEncoderBatch; 33 | import org.jpmml.converter.testing.OptionsUtil; 34 | import org.jpmml.evaluator.ResultField; 35 | import org.jpmml.model.ReflectionUtil; 36 | import org.jpmml.xgboost.FeatureMap; 37 | import org.jpmml.xgboost.HasXGBoostOptions; 38 | import org.jpmml.xgboost.Learner; 39 | import org.jpmml.xgboost.XGBoostUtil; 40 | 41 | abstract 42 | public class XGBoostEncoderBatch extends ModelEncoderBatch { 43 | 44 | private String[] formats = {XGBoostFormats.BINARY, XGBoostFormats.JSON, XGBoostFormats.UBJSON}; 45 | 46 | { 47 | String format = System.getProperty(XGBoostEncoderBatch.class.getName() + ".format", null); 48 | 49 | if(format != null){ 50 | this.formats = format.split(","); 51 | } 52 | } 53 | 54 | public XGBoostEncoderBatch(String algorithm, String dataset, Predicate columnFilter, Equivalence equivalence){ 55 | super(algorithm, dataset, columnFilter, equivalence); 56 | } 57 | 58 | @Override 59 | abstract 60 | public XGBoostEncoderBatchTest getArchiveBatchTest(); 61 | 62 | @Override 63 | public List> getOptionsMatrix(){ 64 | String dataset = getDataset(); 65 | 66 | Integer ntreeLimit = null; 67 | 68 | int index = dataset.indexOf('@'); 69 | if(index > -1){ 70 | ntreeLimit = Integer.valueOf(dataset.substring(index + 1)); 71 | } 72 | 73 | Map options = new LinkedHashMap<>(); 74 | options.put(HasXGBoostOptions.OPTION_MISSING, Float.NaN); 75 | options.put(HasXGBoostOptions.OPTION_COMPACT, new Boolean[]{false, true}); 76 | options.put(HasXGBoostOptions.OPTION_PRUNE, true); 77 | options.put(HasXGBoostOptions.OPTION_NTREE_LIMIT, ntreeLimit); 78 | 79 | return OptionsUtil.generateOptionsMatrix(options); 80 | } 81 | 82 | public String getLearnerPath(String format){ 83 | return "/xgboost/" + (getAlgorithm() + truncate(getDataset())) + "." + format; 84 | } 85 | 86 | public String getFeatureMapPath(){ 87 | return "/csv/" + truncate(getDataset()) + ".fmap"; 88 | } 89 | 90 | @Override 91 | public PMML getPMML() throws Exception { 92 | PMML result = null; 93 | 94 | String[] formats = getFormats(); 95 | for(String format : formats){ 96 | PMML pmml = loadPMML(getLearnerPath(format), getFeatureMapPath()); 97 | 98 | if(result != null){ 99 | assertEquals(result, pmml); 100 | } 101 | 102 | result = pmml; 103 | } 104 | 105 | return result; 106 | } 107 | 108 | @Override 109 | public String getInputCsvPath(){ 110 | return "/csv/" + truncate(getDataset()) + ".csv"; 111 | } 112 | 113 | @Override 114 | public String getOutputCsvPath(){ 115 | return super.getOutputCsvPath(); 116 | } 117 | 118 | public String[] getFormats(){ 119 | return this.formats; 120 | } 121 | 122 | public void setFormats(String[] formats){ 123 | this.formats = Objects.requireNonNull(formats); 124 | } 125 | 126 | protected PMML loadPMML(String learnerPath, String featureMapPath) throws Exception { 127 | Learner learner; 128 | 129 | try(InputStream is = open(learnerPath)){ 130 | learner = XGBoostUtil.loadLearner(is); 131 | } 132 | 133 | FeatureMap featureMap; 134 | 135 | try(InputStream is = open(featureMapPath)){ 136 | featureMap = XGBoostUtil.loadFeatureMap(is); 137 | } 138 | 139 | Map options = getOptions(); 140 | 141 | Integer ntreeLimit = (Integer)options.get(HasXGBoostOptions.OPTION_NTREE_LIMIT); 142 | if(ntreeLimit == null){ 143 | Integer bestIteration = learner.getBestIteration(); 144 | 145 | if(bestIteration != null){ 146 | options.put(HasXGBoostOptions.OPTION_NTREE_LIMIT, bestIteration + 1); 147 | } 148 | } 149 | 150 | PMML pmml = learner.encodePMML(options, null, null, featureMap); 151 | 152 | validatePMML(pmml); 153 | 154 | return pmml; 155 | } 156 | 157 | private void assertEquals(PMML left, PMML right){ 158 | Header leftHeader = left.requireHeader(); 159 | Header rightHeader = right.requireHeader(); 160 | 161 | Timestamp leftTimestamp = leftHeader.getTimestamp(); 162 | Timestamp rightTimestamp = rightHeader.getTimestamp(); 163 | 164 | try { 165 | leftHeader.setTimestamp(null); 166 | rightHeader.setTimestamp(null); 167 | 168 | boolean equals = ReflectionUtil.equals(left, right); 169 | if(!equals){ 170 | throw new AssertionError(); 171 | } 172 | } finally { 173 | leftHeader.setTimestamp(leftTimestamp); 174 | rightHeader.setTimestamp(rightTimestamp); 175 | } 176 | } 177 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/csv/LinearRegressionAuto.csv: -------------------------------------------------------------------------------- 1 | _target 2 | 16.334452 3 | 15.539471 4 | 15.539471 5 | 15.539471 6 | 16.334452 7 | 14.094223 8 | 14.094223 9 | 14.094223 10 | 13.794793 11 | 14.454399 12 | 15.539471 13 | 15.539471 14 | 14.454399 15 | 16.540243 16 | 24.114742 17 | 19.263681 18 | 18.913465 19 | 21.07003 20 | 26.683872 21 | 28.609556 22 | 23.355755 23 | 23.582851 24 | 24.023846 25 | 24.103476 26 | 20.84578 27 | 12.762229 28 | 13.054367 29 | 13.054367 30 | 11.876721 31 | 26.752604 32 | 24.240902 33 | 24.331799 34 | 20.65705 35 | 17.68489 36 | 17.586254 37 | 17.745846 38 | 17.68489 39 | 14.26375 40 | 13.964322 41 | 14.26375 42 | 14.26375 43 | 13.672184 44 | 13.672184 45 | 13.672184 46 | 18.876587 47 | 23.85967 48 | 17.67715 49 | 17.836742 50 | 24.331799 51 | 26.752604 52 | 29.70589 53 | 28.111217 54 | 30.872192 55 | 31.069412 56 | 28.559721 57 | 29.239887 58 | 23.455687 59 | 26.470566 60 | 24.056463 61 | 21.98086 62 | 23.455687 63 | 13.576404 64 | 13.276975 65 | 13.576404 66 | 13.576404 67 | 14.8229885 68 | 12.976155 69 | 12.984837 70 | 13.276975 71 | 13.276975 72 | 19.265144 73 | 13.737913 74 | 14.371382 75 | 14.280485 76 | 13.576404 77 | 20.88875 78 | 22.772154 79 | 20.162834 80 | 26.14798 81 | 22.77547 82 | 23.455687 83 | 22.706776 84 | 26.034954 85 | 25.876492 86 | 13.576404 87 | 14.8229885 88 | 13.576404 89 | 14.371382 90 | 13.737913 91 | 12.976155 92 | 13.276975 93 | 13.576404 94 | 13.576404 95 | 12.976155 96 | 12.976155 97 | 13.737913 98 | 17.487814 99 | 16.791786 100 | 18.68725 101 | 18.748205 102 | 19.037466 103 | 26.615461 104 | 12.984837 105 | 12.984837 106 | 12.984837 107 | 12.984837 108 | 18.778147 109 | 22.661076 110 | 22.574934 111 | 22.77547 112 | 20.09957 113 | 22.827898 114 | 21.76871 115 | 23.455687 116 | 13.576404 117 | 13.567722 118 | 27.989265 119 | 25.944057 120 | 22.730167 121 | 20.797853 122 | 14.8229885 123 | 22.570576 124 | 19.594957 125 | 14.8229885 126 | 19.30404 127 | 18.953825 128 | 17.655752 129 | 29.937807 130 | 24.233658 131 | 30.339117 132 | 24.233658 133 | 16.69104 134 | 17.655752 135 | 17.754389 136 | 15.128222 137 | 13.741682 138 | 14.03382 139 | 14.445762 140 | 14.242352 141 | 26.96119 142 | 30.135027 143 | 25.009464 144 | 31.687517 145 | 29.937807 146 | 27.425575 147 | 27.487698 148 | 25.15779 149 | 23.723907 150 | 23.792603 151 | 30.135027 152 | 17.844482 153 | 17.586254 154 | 18.693098 155 | 18.693098 156 | 14.092077 157 | 14.384215 158 | 14.384215 159 | 14.092077 160 | 16.942852 161 | 16.844215 162 | 17.218653 163 | 17.102444 164 | 18.975224 165 | 17.797516 166 | 16.305313 167 | 27.384315 168 | 23.92069 169 | 18.884327 170 | 23.72347 171 | 23.417513 172 | 25.490019 173 | 23.303225 174 | 20.14776 175 | 30.183046 176 | 17.844482 177 | 23.417513 178 | 21.64479 179 | 21.576096 180 | 23.257921 181 | 32.13475 182 | 24.448158 183 | 25.651396 184 | 24.386036 185 | 25.498377 186 | 27.545692 187 | 15.8910475 188 | 15.096068 189 | 16.181482 190 | 15.096068 191 | 18.517214 192 | 18.509474 193 | 20.470316 194 | 19.876242 195 | 31.585197 196 | 27.304995 197 | 29.65265 198 | 31.114244 199 | 18.517214 200 | 19.525421 201 | 18.418577 202 | 18.578169 203 | 29.137823 204 | 30.027758 205 | 27.545692 206 | 24.98011 207 | 21.271105 208 | 15.096068 209 | 21.233477 210 | 21.042206 211 | 18.522331 212 | 14.79664 213 | 15.096068 214 | 16.052559 215 | 15.257579 216 | 30.69236 217 | 29.354118 218 | 34.28244 219 | 25.3718 220 | 32.437054 221 | 16.012115 222 | 17.849672 223 | 15.850605 224 | 16.645586 225 | 19.173115 226 | 19.173115 227 | 19.173115 228 | 18.975895 229 | 15.850605 230 | 15.850605 231 | 15.850605 232 | 15.850605 233 | 30.179163 234 | 23.153706 235 | 27.368925 236 | 23.153706 237 | 30.88958 238 | 30.088266 239 | 30.88958 240 | 29.354118 241 | 21.635984 242 | 23.375189 243 | 21.637104 244 | 37.470806 245 | 33.90074 246 | 34.870102 247 | 33.993797 248 | 34.89132 249 | 19.555511 250 | 17.863459 251 | 18.154205 252 | 19.237926 253 | 19.594738 254 | 20.84729 255 | 25.19785 256 | 19.435146 257 | 19.594738 258 | 19.435146 259 | 20.84729 260 | 19.237926 261 | 19.170317 262 | 17.359226 263 | 18.084904 264 | 18.154205 265 | 17.32751 266 | 31.8185 267 | 25.597883 268 | 27.05707 269 | 29.213787 270 | 25.597883 271 | 23.0914 272 | 23.448162 273 | 25.438292 274 | 22.973423 275 | 20.342854 276 | 22.973423 277 | 20.251957 278 | 31.933128 279 | 32.345 280 | 20.26747 281 | 21.679613 282 | 25.918346 283 | 20.427061 284 | 20.26747 285 | 18.230448 286 | 18.986528 287 | 18.159834 288 | 18.230448 289 | 17.364855 290 | 17.364855 291 | 20.123005 292 | 17.364855 293 | 33.837425 294 | 35.40355 295 | 34.085716 296 | 29.922878 297 | 27.33594 298 | 19.683193 299 | 27.280249 300 | 21.51313 301 | 32.9689 302 | 32.9689 303 | 35.20633 304 | 34.729908 305 | 27.983181 306 | 26.48615 307 | 26.48615 308 | 28.383215 309 | 37.37299 310 | 37.370617 311 | 34.671833 312 | 37.83662 313 | 29.2777 314 | 27.212866 315 | 27.212866 316 | 21.72158 317 | 35.569153 318 | 30.29661 319 | 32.454544 320 | 32.39753 321 | 33.674854 322 | 37.83662 323 | 28.84506 324 | 37.83662 325 | 41.313625 326 | 40.749374 327 | 30.788517 328 | 30.40151 329 | 39.162407 330 | 36.277096 331 | 37.370617 332 | 28.079908 333 | 28.26442 334 | 32.39753 335 | 33.526527 336 | 30.4123 337 | 30.210432 338 | 28.452528 339 | 25.35416 340 | 30.627085 341 | 37.71449 342 | 36.410286 343 | 36.838184 344 | 34.614517 345 | 35.964775 346 | 35.69599 347 | 35.69599 348 | 33.72735 349 | 34.4615 350 | 30.44851 351 | 33.770824 352 | 33.770824 353 | 31.637308 354 | 28.882372 355 | 30.363451 356 | 27.811676 357 | 26.38334 358 | 25.486488 359 | 25.130762 360 | 21.179623 361 | 21.419037 362 | 21.840202 363 | 20.902798 364 | 29.28899 365 | 29.28899 366 | 29.919235 367 | 30.110495 368 | 31.644148 369 | 27.539352 370 | 27.421375 371 | 34.923824 372 | 36.11484 373 | 36.11484 374 | 35.569645 375 | 34.88035 376 | 33.153866 377 | 35.002674 378 | 33.127014 379 | 36.80414 380 | 36.71324 381 | 36.71324 382 | 25.833448 383 | 25.945599 384 | 29.577106 385 | 22.7988 386 | 29.730125 387 | 32.80703 388 | 27.421375 389 | 27.421375 390 | 39.864025 391 | 32.80703 392 | 31.13779 393 | 31.13779 394 | -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/csv/LinearRegressionAutoNA.csv: -------------------------------------------------------------------------------- 1 | _target 2 | 14.140115 3 | 16.39039 4 | 15.47619 5 | 14.140115 6 | 19.771154 7 | 15.450556 8 | 16.39039 9 | 12.584867 10 | 14.270368 11 | 13.107999 12 | 13.676844 13 | 15.092117 14 | 15.47619 15 | 13.676844 16 | 24.220873 17 | 23.131416 18 | 18.189734 19 | 20.271524 20 | 27.48584 21 | 32.51049 22 | 27.956617 23 | 25.270533 24 | 25.270533 25 | 22.675451 26 | 20.271524 27 | 12.231033 28 | 13.048138 29 | 14.270368 30 | 15.125253 31 | 27.590208 32 | 25.249207 33 | 24.645355 34 | 22.84528 35 | 18.578217 36 | 20.159637 37 | 20.159637 38 | 18.578217 39 | 13.65121 40 | 12.97335 41 | 14.065328 42 | 14.772696 43 | 12.619517 44 | 12.619517 45 | 12.619517 46 | 17.242146 47 | 24.499226 48 | 20.159637 49 | 18.054207 50 | 23.027935 51 | 25.307922 52 | 29.158966 53 | 27.535402 54 | 31.522358 55 | 28.759275 56 | 30.105848 57 | 29.16493 58 | 24.220873 59 | 23.393549 60 | 24.955595 61 | 22.288515 62 | 25.213207 63 | 14.270368 64 | 14.270368 65 | 15.47619 66 | 15.336711 67 | 16.196968 68 | 14.030379 69 | 14.030379 70 | 13.676844 71 | 13.65121 72 | 17.557976 73 | 14.140115 74 | 14.3842125 75 | 16.056534 76 | 14.3842125 77 | 20.557661 78 | 22.493322 79 | 23.905935 80 | 27.302692 81 | 22.639452 82 | 25.306532 83 | 24.220873 84 | 25.306532 85 | 25.306532 86 | 12.584867 87 | 14.511467 88 | 12.584867 89 | 14.3842125 90 | 13.107999 91 | 14.030379 92 | 12.584867 93 | 16.39039 94 | 13.676844 95 | 15.47619 96 | 13.297377 97 | 13.107999 98 | 18.189734 99 | 19.963427 100 | 18.189734 101 | 16.853662 102 | 20.557661 103 | 24.533802 104 | 13.916534 105 | 13.676844 106 | 14.030379 107 | 13.916534 108 | 19.771154 109 | 24.919596 110 | 24.89827 111 | 21.852945 112 | 23.21191 113 | 22.288515 114 | 21.852945 115 | 21.852945 116 | 15.994045 117 | 15.593264 118 | 31.689222 119 | 24.82435 120 | 26.794628 121 | 20.557661 122 | 16.39039 123 | 21.888945 124 | 20.557661 125 | 16.250597 126 | 20.371061 127 | 18.132305 128 | 16.796234 129 | 31.421276 130 | 27.441174 131 | 29.018942 132 | 22.452852 133 | 15.840923 134 | 18.721851 135 | 18.78964 136 | 14.155422 137 | 14.382239 138 | 18.116837 139 | 14.402227 140 | 16.076096 141 | 26.678724 142 | 27.16478 143 | 26.075247 144 | 30.85866 145 | 31.242365 146 | 27.240894 147 | 28.311592 148 | 25.061586 149 | 24.82078 150 | 25.24578 151 | 31.242365 152 | 19.390278 153 | 17.242146 154 | 19.81488 155 | 19.81488 156 | 15.001194 157 | 14.559505 158 | 14.559505 159 | 15.593264 160 | 17.271969 161 | 15.935897 162 | 15.935897 163 | 18.211811 164 | 18.578217 165 | 16.754652 166 | 15.418579 167 | 27.210693 168 | 24.850163 169 | 18.578217 170 | 22.917805 171 | 25.213207 172 | 25.884861 173 | 22.241428 174 | 20.159637 175 | 31.126606 176 | 18.578217 177 | 22.241428 178 | 24.645355 179 | 23.063934 180 | 22.241428 181 | 32.120506 182 | 26.942444 183 | 24.0158 184 | 23.524857 185 | 26.978443 186 | 27.64927 187 | 16.44156 188 | 18.049944 189 | 16.44156 190 | 13.730744 191 | 20.78573 192 | 17.868238 193 | 25.359383 194 | 19.861645 195 | 31.935066 196 | 32.679058 197 | 31.011703 198 | 27.53955 199 | 19.20495 200 | 20.747372 201 | 17.868238 202 | 18.525574 203 | 33.333538 204 | 31.687098 205 | 28.698929 206 | 24.51617 207 | 22.90352 208 | 14.691421 209 | 23.089489 210 | 22.474081 211 | 20.225094 212 | 15.53009 213 | 15.416245 214 | 15.154692 215 | 14.38808 216 | 32.967487 217 | 29.280596 218 | 34.39263 219 | 23.133024 220 | 32.040157 221 | 17.17843 222 | 16.827494 223 | 18.797009 224 | 16.10789 225 | 18.133741 226 | 18.812477 227 | 18.813118 228 | 17.70327 229 | 16.420069 230 | 15.846902 231 | 13.65121 232 | 15.336711 233 | 33.333538 234 | 23.95553 235 | 28.42764 236 | 23.95553 237 | 33.68767 238 | 28.691452 239 | 33.68767 240 | 28.10229 241 | 21.051233 242 | 23.262196 243 | 23.788525 244 | 34.224285 245 | 34.224285 246 | 34.754128 247 | 32.292435 248 | 33.840576 249 | 22.34491 250 | 21.299091 251 | 17.008389 252 | 20.232279 253 | 18.650858 254 | 21.956427 255 | 25.213207 256 | 19.71767 257 | 19.001795 258 | 20.375006 259 | 19.390278 260 | 17.336828 261 | 18.770082 262 | 17.008389 263 | 18.732943 264 | 15.184821 265 | 17.44827 266 | 32.32492 267 | 24.824724 268 | 26.406145 269 | 28.634111 270 | 24.038218 271 | 24.203388 272 | 24.4627 273 | 21.956427 274 | 23.96213 275 | 20.712387 276 | 24.203388 277 | 21.10087 278 | 30.037134 279 | 32.84728 280 | 20.314363 281 | 22.168564 282 | 26.21871 283 | 22.376774 284 | 20.763489 285 | 17.805738 286 | 16.740177 287 | 15.450556 288 | 20.081654 289 | 18.362047 290 | 18.89659 291 | 20.772102 292 | 17.392609 293 | 33.720818 294 | 34.541565 295 | 30.447464 296 | 26.969217 297 | 26.884977 298 | 20.738989 299 | 25.753025 300 | 17.70327 301 | 30.096954 302 | 32.392303 303 | 31.650656 304 | 34.349625 305 | 26.969217 306 | 26.18271 307 | 23.131416 308 | 26.21871 309 | 36.78054 310 | 36.555412 311 | 36.78054 312 | 37.093666 313 | 28.298687 314 | 25.249207 315 | 27.98375 316 | 22.91133 317 | 34.477535 318 | 29.085194 319 | 32.894585 320 | 30.666615 321 | 34.100864 322 | 38.61043 323 | 28.463858 324 | 36.05833 325 | 38.61043 326 | 29.479868 327 | 31.352356 328 | 27.397045 329 | 34.541565 330 | 36.783733 331 | 35.64186 332 | 26.34607 333 | 27.02482 334 | 27.32066 335 | 30.379766 336 | 29.861858 337 | 29.022594 338 | 24.4627 339 | 24.4267 340 | 29.861858 341 | 35.250027 342 | 36.676235 343 | 37.615383 344 | 29.045586 345 | 37.615383 346 | 36.676235 347 | 33.037296 348 | 31.163376 349 | 33.68767 350 | 31.453093 351 | 33.02623 352 | 29.058594 353 | 33.67303 354 | 28.237286 355 | 31.092342 356 | 28.17371 357 | 25.216656 358 | 24.894768 359 | 22.474081 360 | 23.630602 361 | 23.863506 362 | 23.392385 363 | 21.810965 364 | 30.733135 365 | 24.075764 366 | 30.733135 367 | 27.920618 368 | 30.335133 369 | 25.249207 370 | 27.003405 371 | 31.105568 372 | 36.94055 373 | 33.354576 374 | 37.134674 375 | 36.78054 376 | 32.249565 377 | 35.168713 378 | 29.438448 379 | 37.093666 380 | 37.093666 381 | 35.455116 382 | 22.474081 383 | 24.635477 384 | 28.298687 385 | 24.635477 386 | 24.4267 387 | 33.998344 388 | 29.121193 389 | 27.003405 390 | 37.134674 391 | 34.034344 392 | 26.794628 393 | 32.543644 394 | -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/ObjFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import java.util.ArrayList; 22 | import java.util.Iterator; 23 | import java.util.List; 24 | import java.util.function.Function; 25 | 26 | import org.dmg.pmml.MathContext; 27 | import org.dmg.pmml.MiningFunction; 28 | import org.dmg.pmml.mining.MiningModel; 29 | import org.dmg.pmml.mining.Segmentation; 30 | import org.dmg.pmml.tree.TreeModel; 31 | import org.jpmml.converter.ContinuousLabel; 32 | import org.jpmml.converter.Label; 33 | import org.jpmml.converter.ModelEncoder; 34 | import org.jpmml.converter.ModelUtil; 35 | import org.jpmml.converter.PredicateManager; 36 | import org.jpmml.converter.Schema; 37 | import org.jpmml.converter.ValueUtil; 38 | import org.jpmml.converter.mining.MiningModelUtil; 39 | 40 | abstract 41 | public class ObjFunction { 42 | 43 | private String name; 44 | 45 | 46 | public ObjFunction(String name){ 47 | this.name = name; 48 | } 49 | 50 | abstract 51 | public Label encodeLabel(String targetName, List targetCategories, ModelEncoder encoder); 52 | 53 | abstract 54 | public MiningModel encodeModel(List trees, List weights, float[] base_score, Integer ntreeLimit, Schema schema); 55 | 56 | public MiningModel encodeModel(int targetIndex, List trees, List weights, float[] base_score, Integer ntreeLimit, Schema schema){ 57 | return encodeModel(trees, weights, targetBaseScore(targetIndex, base_score), ntreeLimit, schema); 58 | } 59 | 60 | public float[] probToMargin(float[] base_score){ 61 | ProbToMarginFunction function = probToMarginFunction(); 62 | 63 | float[] result = new float[base_score.length]; 64 | 65 | for(int i = 0; i < base_score.length; i++){ 66 | result[i] = function.apply(base_score[i]); 67 | } 68 | 69 | return result; 70 | } 71 | 72 | public ProbToMarginFunction probToMarginFunction(){ 73 | return (x) -> x; 74 | } 75 | 76 | public String getName(){ 77 | return this.name; 78 | } 79 | 80 | static 81 | protected MiningModel createMiningModel(List trees, List weights, float[] base_score, Integer ntreeLimit, Schema schema){ 82 | trees = new ArrayList<>(trees); 83 | 84 | if(weights != null){ 85 | weights = new ArrayList<>(weights); 86 | 87 | if(trees.size() != weights.size()){ 88 | throw new IllegalArgumentException(); 89 | } 90 | } // End if 91 | 92 | if(ntreeLimit != null){ 93 | 94 | if(ntreeLimit > trees.size()){ 95 | throw new IllegalArgumentException("Tree limit " + ntreeLimit + " is greater than the number of trees"); 96 | } 97 | 98 | trees = trees.subList(0, ntreeLimit); 99 | 100 | if(weights != null){ 101 | weights = weights.subList(0, ntreeLimit); 102 | } 103 | } 104 | 105 | ContinuousLabel continuousLabel = (ContinuousLabel)schema.getLabel(); 106 | 107 | Schema segmentSchema = schema.toAnonymousSchema(); 108 | 109 | PredicateManager predicateManager = new PredicateManager(); 110 | 111 | List treeModels = new ArrayList<>(); 112 | 113 | Number intercept = base_score[0]; 114 | 115 | boolean equalWeights = true; 116 | 117 | // First filtering pass - eliminating empty trees 118 | { 119 | Iterator treeIt = trees.iterator(); 120 | Iterator weightIt = (weights != null ? weights.iterator() : null); 121 | 122 | while(treeIt.hasNext()){ 123 | RegTree tree = treeIt.next(); 124 | Float weight = (weightIt != null ? weightIt.next() : null); 125 | 126 | Float leafValue = tree.getLeafValue(); 127 | if(leafValue != null && ValueUtil.isZero(leafValue)){ 128 | treeIt.remove(); 129 | 130 | if(weightIt != null){ 131 | weightIt.remove(); 132 | } 133 | 134 | continue; 135 | } // End if 136 | 137 | if(weight != null){ 138 | equalWeights &= ValueUtil.isOne(weight); 139 | } 140 | } 141 | } 142 | 143 | // Second filtering pass - eliminating constant-prediction trees 144 | if(equalWeights){ 145 | Iterator treeIt = trees.iterator(); 146 | Iterator weightIt = (weights != null ? weights.iterator() : null); 147 | 148 | while(treeIt.hasNext()){ 149 | RegTree tree = treeIt.next(); 150 | Float weight = (weightIt != null ? weightIt.next() : null); 151 | 152 | Float leafValue = tree.getLeafValue(); 153 | if(leafValue != null){ 154 | intercept = ValueUtil.add(MathContext.FLOAT, intercept, leafValue); 155 | 156 | treeIt.remove(); 157 | 158 | if(weightIt != null){ 159 | weightIt.remove(); 160 | } 161 | } 162 | } 163 | } 164 | 165 | // Final pass - encoding trees 166 | { 167 | for(RegTree tree : trees){ 168 | TreeModel treeModel = tree.encodeTreeModel(predicateManager, segmentSchema); 169 | 170 | treeModels.add(treeModel); 171 | } 172 | } 173 | 174 | MiningModel miningModel = new MiningModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(continuousLabel)) 175 | .setMathContext(MathContext.FLOAT) 176 | .setSegmentation(MiningModelUtil.createSegmentation(equalWeights ? Segmentation.MultipleModelMethod.SUM : Segmentation.MultipleModelMethod.WEIGHTED_SUM, Segmentation.MissingPredictionTreatment.RETURN_MISSING, treeModels, weights)) 177 | .setTargets(ModelUtil.createRescaleTargets(null, intercept, continuousLabel)); 178 | 179 | return miningModel; 180 | } 181 | 182 | static 183 | protected float[] targetBaseScore(int targetIndex, float[] base_score){ 184 | 185 | if(targetIndex == ObjFunction.DEFAULT_TARGET_INDEX){ 186 | return base_score; 187 | } // End if 188 | 189 | if(base_score.length == 1){ 190 | return base_score; 191 | } 192 | 193 | return new float[]{base_score[targetIndex]}; 194 | } 195 | 196 | static 197 | protected float inverseLogit(float value){ 198 | return (float)-Math.log((1f / value) - 1f); 199 | } 200 | 201 | static 202 | protected float inverseExp(float value){ 203 | return (float)Math.log(value); 204 | } 205 | 206 | static 207 | public interface ProbToMarginFunction extends Function { 208 | } 209 | 210 | public static final int DEFAULT_TARGET_INDEX = -1; 211 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/csv/LungNA.csv: -------------------------------------------------------------------------------- 1 | age,sex,ph.ecog,ph.karno,pat.karno,meal.cal,wt.loss,time,status 2 | 74,1,1,90,100,1175,NA,306,1 3 | 68,1,0,90,90,1225,15,455,1 4 | 56,1,0,90,90,NA,15,1010,0 5 | 57,1,1,90,60,1150,11,210,1 6 | 60,1,0,100,90,NA,0,883,1 7 | 74,1,1,50,80,513,0,1022,0 8 | 68,2,2,70,60,384,10,310,1 9 | 71,2,2,60,80,538,1,361,1 10 | 53,1,1,70,80,825,16,218,1 11 | 61,1,2,70,70,271,34,166,1 12 | 57,1,1,80,80,1025,27,170,1 13 | 68,2,2,70,70,NA,23,654,1 14 | 68,2,1,90,90,NA,5,728,1 15 | 60,1,NA,60,70,1225,32,71,1 16 | 57,1,1,80,70,2600,60,567,1 17 | 67,1,1,80,90,NA,15,144,1 18 | 70,1,1,90,100,1150,-5,613,1 19 | 63,1,2,50,70,1025,22,707,1 20 | 56,2,2,60,60,238,10,61,1 21 | 57,1,1,90,80,1175,NA,88,1 22 | 67,1,1,80,80,1025,17,301,1 23 | 49,2,0,100,70,1175,-8,81,1 24 | 50,1,1,70,80,NA,16,624,1 25 | 58,1,0,90,100,975,13,371,1 26 | 72,1,0,90,80,NA,0,394,1 27 | 70,2,1,90,80,825,6,520,1 28 | 60,1,0,100,100,1025,-13,574,1 29 | 70,1,3,60,70,1075,20,118,1 30 | 53,1,1,80,70,875,-7,390,1 31 | 74,1,2,70,50,305,20,12,1 32 | 69,2,1,90,90,1025,-1,473,1 33 | 73,1,2,60,70,388,20,26,1 34 | 48,1,2,60,80,NA,-11,533,1 35 | 60,2,2,50,60,925,-15,107,1 36 | 61,1,2,70,100,1075,10,53,1 37 | 62,2,2,50,50,1025,NA,122,1 38 | 65,1,2,70,60,513,28,814,1 39 | 66,2,1,70,90,875,4,965,0 40 | 74,1,2,50,40,1225,24,93,1 41 | 64,2,1,80,100,1175,15,731,1 42 | 70,1,1,80,60,975,10,460,1 43 | 73,2,2,60,70,1075,11,153,1 44 | 59,2,0,90,90,363,27,433,1 45 | 60,2,2,70,60,NA,NA,145,1 46 | 68,1,1,60,70,1025,7,583,1 47 | 76,2,2,60,60,625,-24,95,1 48 | 74,1,0,90,70,463,30,303,1 49 | 63,1,1,80,70,1025,10,519,1 50 | 74,1,0,90,90,1425,2,643,1 51 | 50,2,1,90,100,1175,4,765,1 52 | 72,2,1,90,90,NA,9,735,1 53 | 63,1,0,80,70,NA,0,189,1 54 | 68,1,0,90,100,1025,0,53,1 55 | 58,1,0,100,90,1175,7,246,1 56 | 59,1,1,90,80,1300,15,689,1 57 | 62,1,0,90,80,725,NA,65,1 58 | 65,2,0,100,80,338,5,5,1 59 | 57,1,2,70,60,NA,18,132,1 60 | 58,2,1,80,80,1225,10,687,1 61 | 64,2,1,90,80,1075,-3,345,1 62 | 75,2,2,70,70,438,8,444,1 63 | 48,1,1,90,80,1300,68,223,1 64 | 73,1,1,80,100,1025,NA,175,1 65 | 65,2,1,90,80,1025,0,60,1 66 | 69,1,1,80,60,1125,0,163,1 67 | 68,1,2,70,50,825,8,65,1 68 | 67,2,2,70,NA,538,2,208,1 69 | 64,2,0,90,70,1025,3,821,0 70 | 68,1,0,100,80,1039,0,428,1 71 | 67,1,1,80,100,488,23,230,1 72 | 63,1,0,90,90,1175,-1,840,0 73 | 48,2,1,80,90,538,29,305,1 74 | 74,1,2,70,100,1175,0,11,1 75 | 40,1,1,80,80,NA,3,132,1 76 | 53,2,1,90,80,825,3,226,1 77 | 71,2,1,90,90,1075,19,426,1 78 | 51,2,0,100,80,1300,0,705,1 79 | 56,2,1,80,70,1225,-2,363,1 80 | 81,1,0,90,NA,731,15,11,1 81 | 73,1,0,90,70,169,30,176,1 82 | 59,1,0,100,80,768,5,791,1 83 | 55,1,1,70,90,1500,15,95,1 84 | 42,1,1,80,80,1425,8,196,0 85 | 44,2,1,80,90,588,-1,167,1 86 | 44,1,1,80,80,1025,1,806,0 87 | 71,1,1,80,90,1100,14,284,1 88 | 62,2,1,80,80,1150,1,641,1 89 | 61,1,0,100,90,1175,4,147,1 90 | 44,2,1,90,80,588,39,740,0 91 | 72,1,2,70,70,910,2,163,1 92 | 63,1,0,100,90,975,-1,655,1 93 | 70,1,1,80,100,NA,23,239,1 94 | 66,1,1,90,80,875,8,88,1 95 | 57,2,1,80,60,280,14,245,1 96 | 69,2,0,100,90,NA,13,588,0 97 | 72,1,2,80,60,288,7,30,1 98 | 69,1,1,80,80,NA,25,179,1 99 | 71,1,1,90,100,NA,0,310,1 100 | 64,1,1,90,100,910,0,477,1 101 | 70,2,0,90,70,NA,10,166,1 102 | 58,2,0,100,100,710,15,559,0 103 | 69,2,1,80,90,1175,3,450,1 104 | 56,1,1,70,80,NA,4,364,1 105 | 63,1,1,90,70,NA,0,107,1 106 | 59,1,2,50,NA,NA,32,177,1 107 | 66,1,1,80,90,875,14,156,1 108 | 54,2,1,80,100,975,-3,529,0 109 | 67,1,1,90,90,925,NA,11,1 110 | 55,1,1,100,80,975,5,429,1 111 | 75,2,2,60,50,925,11,351,1 112 | 69,1,0,90,70,575,10,15,1 113 | 44,1,1,80,90,1175,5,181,1 114 | 80,1,1,80,100,1030,6,283,1 115 | 75,2,0,90,100,NA,1,201,1 116 | 54,2,1,80,100,NA,15,524,1 117 | 76,1,2,70,70,413,20,13,1 118 | 49,1,2,70,60,675,20,212,1 119 | 68,1,2,60,70,1300,30,524,1 120 | 66,1,2,70,60,613,24,288,1 121 | 80,1,1,80,90,346,11,363,1 122 | 75,1,0,90,90,NA,0,442,1 123 | 60,2,2,70,80,675,10,199,1 124 | 69,2,1,70,80,910,0,550,1 125 | 72,1,2,60,60,768,-3,54,1 126 | 70,1,0,90,90,1025,17,558,1 127 | 66,1,1,80,80,925,20,207,1 128 | 50,1,1,80,60,1075,13,92,1 129 | 64,1,1,80,90,993,0,60,1 130 | 77,2,2,80,60,750,28,551,0 131 | 48,2,0,90,60,NA,4,543,0 132 | 59,2,1,80,80,925,52,293,1 133 | 53,1,1,80,80,NA,20,202,1 134 | 47,1,0,100,90,1225,5,353,1 135 | 55,2,1,80,70,NA,49,511,0 136 | 67,1,0,90,70,313,6,267,1 137 | 74,2,2,60,40,96,37,511,0 138 | 58,2,1,80,70,NA,0,371,1 139 | 56,1,2,80,60,1075,NA,387,1 140 | 54,1,1,90,90,975,-5,457,1 141 | 56,1,0,100,100,1500,15,337,1 142 | 73,2,2,70,60,1225,-16,201,1 143 | 74,1,1,80,70,413,38,404,0 144 | 76,1,2,70,70,1500,8,222,1 145 | 65,2,1,80,90,1075,0,62,1 146 | 57,1,1,80,100,513,30,458,0 147 | 53,2,1,90,90,NA,2,356,0 148 | 71,1,0,100,80,775,2,353,1 149 | 54,1,1,90,80,1225,13,163,1 150 | 82,1,0,100,90,413,27,31,1 151 | 59,2,0,100,90,NA,0,340,1 152 | 70,1,1,70,60,1175,-2,229,1 153 | 60,1,0,90,100,NA,7,444,0 154 | 62,2,0,90,90,NA,0,315,0 155 | 53,2,1,80,60,NA,4,182,1 156 | 55,1,2,70,30,1025,10,156,1 157 | 69,1,2,70,80,713,20,329,1 158 | 68,2,1,90,90,NA,7,364,0 159 | 62,1,2,70,60,475,27,291,1 160 | 63,1,1,80,70,538,-2,179,1 161 | 56,2,1,80,90,825,17,376,0 162 | 62,2,0,90,90,588,8,384,0 163 | 44,2,1,90,100,2450,2,268,1 164 | 69,1,2,60,70,2450,36,292,0 165 | 63,1,1,90,80,875,2,142,1 166 | 64,1,1,80,70,413,16,413,0 167 | 57,2,0,90,90,1075,3,266,0 168 | 60,2,1,80,60,NA,33,194,1 169 | 46,1,0,100,100,860,4,320,1 170 | 61,1,1,90,90,730,0,181,1 171 | 65,1,0,100,90,1025,0,285,1 172 | 61,1,1,90,100,825,2,301,0 173 | 58,2,0,90,80,1225,10,348,1 174 | 56,1,1,90,60,768,37,197,1 175 | 43,2,0,100,90,338,6,382,0 176 | 53,1,1,90,80,1225,12,303,0 177 | 59,2,1,80,100,1025,0,296,0 178 | 56,1,2,60,80,1225,-2,180,1 179 | 55,2,1,80,70,NA,NA,186,1 180 | 53,2,1,80,90,588,13,145,1 181 | 74,2,0,100,100,588,0,269,0 182 | 60,1,0,100,100,975,5,300,0 183 | 39,1,0,100,90,1225,-5,284,0 184 | 66,2,0,90,100,1025,NA,350,1 185 | 65,2,1,80,90,NA,-1,272,0 186 | 51,2,0,90,80,1225,0,292,0 187 | 45,2,0,90,100,975,5,332,0 188 | 72,2,2,70,90,463,20,285,1 189 | 58,1,0,90,80,1300,8,259,0 190 | 64,1,1,80,60,1025,12,110,1 191 | 53,1,0,90,90,1225,8,286,1 192 | 72,1,1,80,90,488,14,270,1 193 | 52,1,2,60,70,1075,NA,81,1 194 | 50,1,1,90,80,513,NA,131,1 195 | 64,1,1,90,80,825,33,225,0 196 | 71,1,1,90,90,1300,-2,269,1 197 | 70,1,0,100,100,1175,6,225,0 198 | 63,2,1,80,90,825,0,243,0 199 | 64,1,1,90,90,NA,4,279,0 200 | 52,2,0,100,80,975,0,276,0 201 | 60,1,1,90,70,1275,0,135,1 202 | 64,2,1,90,90,488,37,79,1 203 | 73,1,1,60,60,2200,5,59,1 204 | 63,2,0,90,100,1025,0,240,0 205 | 50,2,0,100,100,635,1,202,0 206 | 63,2,0,100,90,413,0,235,0 207 | 62,1,2,NA,70,NA,NA,105,1 208 | 55,2,0,80,90,NA,23,224,0 209 | 50,2,2,60,60,1025,-3,239,1 210 | 69,1,1,80,70,NA,NA,237,0 211 | 59,2,1,90,80,NA,10,173,0 212 | 60,2,0,100,90,488,-2,252,0 213 | 67,1,1,80,70,413,23,221,0 214 | 69,1,1,90,70,1075,0,185,0 215 | 64,2,2,70,100,NA,31,92,0 216 | 65,1,1,80,90,NA,10,13,1 217 | 65,1,1,90,70,1025,18,222,0 218 | 41,2,1,90,80,NA,-10,192,0 219 | 76,1,2,80,60,825,7,183,1 220 | 70,2,2,70,30,131,3,211,0 221 | 57,2,0,80,80,725,11,175,0 222 | 67,1,1,80,90,1500,2,197,0 223 | 71,2,1,80,90,1025,0,203,0 224 | 76,1,1,80,80,NA,0,116,1 225 | 77,1,1,80,60,NA,3,188,0 226 | 39,1,0,90,90,2350,-5,191,0 227 | 75,2,2,60,70,1025,5,105,0 228 | 66,1,1,90,100,1075,1,174,0 229 | 58,2,1,80,90,1060,0,177,0 230 | -------------------------------------------------------------------------------- /pmml-xgboost/src/main/java/org/jpmml/xgboost/GBTree.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost; 20 | 21 | import java.io.IOException; 22 | import java.util.ArrayList; 23 | import java.util.Arrays; 24 | import java.util.BitSet; 25 | import java.util.HashSet; 26 | import java.util.List; 27 | import java.util.Set; 28 | 29 | import com.devsmart.ubjson.GsonUtil; 30 | import com.devsmart.ubjson.UBArray; 31 | import com.devsmart.ubjson.UBObject; 32 | import com.devsmart.ubjson.UBValue; 33 | import com.google.common.primitives.Floats; 34 | import com.google.gson.JsonObject; 35 | import org.dmg.pmml.Model; 36 | import org.dmg.pmml.mining.MiningModel; 37 | import org.dmg.pmml.mining.Segmentation; 38 | import org.jpmml.converter.CMatrixUtil; 39 | import org.jpmml.converter.Label; 40 | import org.jpmml.converter.ScalarLabel; 41 | import org.jpmml.converter.ScalarLabelUtil; 42 | import org.jpmml.converter.Schema; 43 | import org.jpmml.converter.mining.MiningModelUtil; 44 | 45 | public class GBTree extends GradientBooster { 46 | 47 | private int num_trees; 48 | 49 | private int num_parallel_tree; 50 | 51 | private int num_roots; 52 | 53 | private int num_feature; 54 | 55 | private int num_output_group; 56 | 57 | private int size_leaf_vector; 58 | 59 | private RegTree[] trees; 60 | 61 | private int[] tree_info; 62 | 63 | 64 | public GBTree(){ 65 | } 66 | 67 | @Override 68 | public String getAlgorithmName(){ 69 | return "GBTree"; 70 | } 71 | 72 | @Override 73 | public void loadBinary(XGBoostDataInput input) throws IOException { 74 | this.num_trees = input.readInt(); 75 | this.num_roots = input.readInt(); 76 | this.num_feature = input.readInt(); 77 | 78 | input.readReserved(3); 79 | 80 | this.num_output_group = input.readInt(); 81 | this.size_leaf_vector = input.readInt(); 82 | 83 | input.readReserved(32); 84 | 85 | this.trees = input.readObjectArray(RegTree.class, this.num_trees); 86 | this.tree_info = input.readIntArray(this.num_trees); 87 | } 88 | 89 | @Override 90 | public void loadJSON(JsonObject gradientBooster){ 91 | UBValue value = GsonUtil.toUBValue(gradientBooster); 92 | 93 | loadUBJSON(value.asObject()); 94 | } 95 | 96 | @Override 97 | public void loadUBJSON(UBObject gradientBooster){ 98 | UBObject model = gradientBooster.get("model").asObject(); 99 | 100 | UBObject gbtreeModelParam = model.get("gbtree_model_param").asObject(); 101 | 102 | this.num_trees = gbtreeModelParam.get("num_trees").asInt(); 103 | 104 | if(gbtreeModelParam.containsKey("num_parallel_tree")){ 105 | this.num_parallel_tree = gbtreeModelParam.get("num_parallel_tree").asInt(); 106 | } else 107 | 108 | { 109 | this.num_parallel_tree = 1; 110 | } // End if 111 | 112 | if(gbtreeModelParam.containsKey("size_leaf_vector")){ 113 | this.size_leaf_vector = gbtreeModelParam.get("size_leaf_vector").asInt(); 114 | } 115 | 116 | UBArray trees = model.get("trees").asArray(); 117 | 118 | this.trees = new RegTree[this.num_trees]; 119 | 120 | for(int i = 0; i < this.num_trees; i++){ 121 | UBObject tree = (trees.get(i)).asObject(); 122 | 123 | this.trees[i] = new RegTree(); 124 | this.trees[i].loadUBJSON(tree); 125 | } 126 | 127 | this.tree_info = UBJSONUtil.toIntArray(model.get("tree_info")); 128 | } 129 | 130 | public boolean hasCategoricalSplits(){ 131 | 132 | for(int i = 0; i < this.num_trees; i++){ 133 | RegTree tree = this.trees[i]; 134 | 135 | if(tree.hasCategoricalSplits()){ 136 | return true; 137 | } 138 | } 139 | 140 | return false; 141 | } 142 | 143 | public Set getSplitType(int splitIndex){ 144 | Set result = new HashSet<>(); 145 | 146 | for(int i = 0; i < this.num_trees; i++){ 147 | RegTree tree = this.trees[i]; 148 | 149 | result.addAll(tree.getSplitType(splitIndex)); 150 | } 151 | 152 | return result; 153 | } 154 | 155 | public BitSet getSplitCategories(int splitIndex){ 156 | BitSet result = null; 157 | 158 | for(int i = 0; i < this.num_trees; i++){ 159 | RegTree tree = this.trees[i]; 160 | 161 | BitSet splitCategories = tree.getSplitCategories(splitIndex); 162 | 163 | if(splitCategories != null){ 164 | 165 | if(result == null){ 166 | result = new BitSet(); 167 | } 168 | 169 | result.or(splitCategories); 170 | } 171 | } 172 | 173 | return result; 174 | } 175 | 176 | public MiningModel encodeModel(ObjFunction obj, float[] base_score, Integer ntreeLimit, Schema schema){ 177 | List trees = Arrays.asList(trees()); 178 | List weights = tree_weights() != null ? Floats.asList(tree_weights()) : null; 179 | 180 | Label label = schema.getLabel(); 181 | 182 | List scalarLabels = ScalarLabelUtil.toScalarLabels(label); 183 | 184 | if(trees.size() % scalarLabels.size() != 0){ 185 | throw new IllegalArgumentException(); 186 | } // End if 187 | 188 | if(scalarLabels.size() == 1){ 189 | return obj.encodeModel(ObjFunction.DEFAULT_TARGET_INDEX, trees, weights, base_score, ntreeLimit, schema); 190 | } else 191 | 192 | if(scalarLabels.size() >= 2){ 193 | List models = new ArrayList<>(); 194 | 195 | for(int i = 0; i < scalarLabels.size(); i++){ 196 | ScalarLabel scalarLabel = scalarLabels.get(i); 197 | 198 | List segmentTrees; 199 | List segmentWeights; 200 | 201 | // Boosting 202 | if(this.num_parallel_tree == 1){ 203 | int rows = trees.size() / scalarLabels.size(); 204 | int columns = scalarLabels.size(); 205 | 206 | segmentTrees = CMatrixUtil.getColumn(trees, rows, columns, i); 207 | segmentWeights = weights != null ? CMatrixUtil.getColumn(weights, rows, columns, i) : null; 208 | } else 209 | 210 | // Bagging 211 | if(this.num_parallel_tree >= 2){ 212 | int rows = scalarLabels.size(); 213 | int columns = trees.size() / scalarLabels.size(); 214 | 215 | segmentTrees = CMatrixUtil.getRow(trees, rows, columns, i); 216 | segmentWeights = weights != null ? CMatrixUtil.getRow(weights, rows, columns, i) : null; 217 | } else 218 | 219 | { 220 | throw new IllegalArgumentException(); 221 | } 222 | 223 | Schema segmentSchema = schema.toRelabeledSchema(scalarLabel); 224 | 225 | Model model = obj.encodeModel(i, segmentTrees, segmentWeights, base_score, ntreeLimit, segmentSchema); 226 | 227 | models.add(model); 228 | } 229 | 230 | return MiningModelUtil.createMultiModelChain(models, Segmentation.MissingPredictionTreatment.CONTINUE); 231 | } else 232 | 233 | { 234 | throw new IllegalArgumentException(); 235 | } 236 | } 237 | 238 | public int num_trees(){ 239 | return this.num_trees; 240 | } 241 | 242 | public int num_parallel_tree(){ 243 | return this.num_parallel_tree; 244 | } 245 | 246 | public RegTree[] trees(){ 247 | return this.trees; 248 | } 249 | 250 | public float[] tree_weights(){ 251 | return null; 252 | } 253 | } -------------------------------------------------------------------------------- /pmml-xgboost-example/src/main/java/org/jpmml/xgboost/example/Main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016 Villu Ruusmann 3 | * 4 | * This file is part of JPMML-XGBoost 5 | * 6 | * JPMML-XGBoost is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Affero General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * JPMML-XGBoost is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Affero General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Affero General Public License 17 | * along with JPMML-XGBoost. If not, see . 18 | */ 19 | package org.jpmml.xgboost.example; 20 | 21 | import java.io.File; 22 | import java.io.FileInputStream; 23 | import java.io.FileOutputStream; 24 | import java.io.InputStream; 25 | import java.io.OutputStream; 26 | import java.nio.ByteOrder; 27 | import java.util.LinkedHashMap; 28 | import java.util.List; 29 | import java.util.Map; 30 | 31 | import com.beust.jcommander.DefaultUsageFormatter; 32 | import com.beust.jcommander.IUsageFormatter; 33 | import com.beust.jcommander.JCommander; 34 | import com.beust.jcommander.Parameter; 35 | import com.beust.jcommander.ParameterException; 36 | import org.dmg.pmml.PMML; 37 | import org.jpmml.model.JAXBSerializer; 38 | import org.jpmml.model.metro.MetroJAXBSerializer; 39 | import org.jpmml.xgboost.ByteOrderUtil; 40 | import org.jpmml.xgboost.FeatureMap; 41 | import org.jpmml.xgboost.HasXGBoostOptions; 42 | import org.jpmml.xgboost.Learner; 43 | import org.jpmml.xgboost.XGBoostUtil; 44 | import org.slf4j.Logger; 45 | import org.slf4j.LoggerFactory; 46 | 47 | public class Main { 48 | 49 | @Parameter ( 50 | names = {"--model-input"}, 51 | description = "XGBoost model input file", 52 | required = true, 53 | order = 1 54 | ) 55 | private File modelInput = null; 56 | 57 | @Parameter ( 58 | names = {"--fmap-input"}, 59 | description = "XGBoost feature map input file", 60 | order = 2 61 | ) 62 | private File fmapInput = null; 63 | 64 | @Parameter ( 65 | names = {"--pmml-output"}, 66 | description = "PMML output file", 67 | required = true, 68 | order = 3 69 | ) 70 | private File pmmlOutput = null; 71 | 72 | @Parameter ( 73 | names = {"--" + HasXGBoostOptions.OPTION_BYTE_ORDER}, 74 | description = "Endianness of XGBoost model input file. Possible values \"BIG_ENDIAN\" (\"BE\") or \"LITTLE_ENDIAN\" (\"LE\")", 75 | order = 4 76 | ) 77 | private String byteOrder = (ByteOrder.nativeOrder()).toString(); 78 | 79 | @Parameter ( 80 | names = {"--" + HasXGBoostOptions.OPTION_CHARSET}, 81 | description = "Charset of XGBoost model input file", 82 | order = 5 83 | ) 84 | private String charset = null; 85 | 86 | @Parameter ( 87 | names = {"--json-path"}, 88 | description = "JSONPath expression of the JSON model element", 89 | order = 6 90 | ) 91 | private String jsonPath = "$"; 92 | 93 | @Parameter ( 94 | names = {"--target-name"}, 95 | description = "Target name. Defaults to \"_target\"", 96 | order = 7 97 | ) 98 | private String targetName = null; 99 | 100 | @Parameter ( 101 | names = {"--target-categories"}, 102 | description = "Target categories. Defaults to 0-based index [0, 1, .., num_class - 1]", 103 | order = 8 104 | ) 105 | private List targetCategories = null; 106 | 107 | @Parameter ( 108 | names = {"--X-" + HasXGBoostOptions.OPTION_MISSING}, 109 | description = "Missing value. Defaults to Not-a-Number (NaN) value", 110 | order = 9 111 | ) 112 | private Float missing = Float.NaN; 113 | 114 | @Parameter ( 115 | names = {"--X-" + HasXGBoostOptions.OPTION_COMPACT}, 116 | description = "Transform XGBoost-style trees to PMML-style trees", 117 | arity = 1, 118 | order = 10 119 | ) 120 | private boolean compact = true; 121 | 122 | @Parameter ( 123 | names = {"--X-" + HasXGBoostOptions.OPTION_INPUT_FLOAT}, 124 | description = "Allow field data type updates", 125 | arity = 1, 126 | order = 11 127 | ) 128 | private Boolean inputFloat = null; 129 | 130 | @Parameter ( 131 | names = {"--X-" + HasXGBoostOptions.OPTION_NUMERIC}, 132 | description = "Simplify non-numeric split conditions to numeric split conditions", 133 | arity = 1, 134 | order = 12 135 | ) 136 | private boolean numeric = true; 137 | 138 | @Parameter ( 139 | names = {"--X-" + HasXGBoostOptions.OPTION_PRUNE}, 140 | description = "Remove unreachable nodes", 141 | arity = 1, 142 | order = 13 143 | ) 144 | private boolean prune = true; 145 | 146 | @Parameter ( 147 | names = {"--X-" + HasXGBoostOptions.OPTION_NTREE_LIMIT}, 148 | description = "Limit the number of trees. Defaults to all trees", 149 | order = 14 150 | ) 151 | private Integer ntreeLimit = null; 152 | 153 | @Parameter ( 154 | names = {"--help"}, 155 | description = "Show the list of configuration options and exit", 156 | help = true, 157 | order = Integer.MAX_VALUE 158 | ) 159 | private boolean help = false; 160 | 161 | 162 | static 163 | public void main(String... args) throws Exception { 164 | Main main = new Main(); 165 | 166 | JCommander commander = new JCommander(main); 167 | commander.setProgramName(Main.class.getName()); 168 | 169 | IUsageFormatter usageFormatter = new DefaultUsageFormatter(commander); 170 | 171 | try { 172 | commander.parse(args); 173 | } catch(ParameterException pe){ 174 | StringBuilder sb = new StringBuilder(); 175 | 176 | sb.append(pe.toString()); 177 | sb.append("\n"); 178 | 179 | usageFormatter.usage(sb); 180 | 181 | System.err.println(sb.toString()); 182 | 183 | System.exit(-1); 184 | } 185 | 186 | if(main.help){ 187 | StringBuilder sb = new StringBuilder(); 188 | 189 | usageFormatter.usage(sb); 190 | 191 | System.out.println(sb.toString()); 192 | 193 | System.exit(0); 194 | } 195 | 196 | main.run(); 197 | } 198 | 199 | private void run() throws Exception { 200 | Learner learner; 201 | 202 | ByteOrder byteOrder = ByteOrderUtil.forValue(this.byteOrder); 203 | 204 | try(InputStream is = new FileInputStream(this.modelInput)){ 205 | logger.info("Parsing learner.."); 206 | 207 | long begin = System.currentTimeMillis(); 208 | learner = XGBoostUtil.loadLearner(is, byteOrder, this.charset, this.jsonPath); 209 | long end = System.currentTimeMillis(); 210 | 211 | logger.info("Parsed learner in {} ms.", (end - begin)); 212 | } catch(Exception e){ 213 | logger.error("Failed to parse learner", e); 214 | 215 | throw e; 216 | } 217 | 218 | FeatureMap featureMap = null; 219 | 220 | if(this.fmapInput != null){ 221 | 222 | try(InputStream is = new FileInputStream(this.fmapInput)){ 223 | logger.info("Parsing feature map.."); 224 | 225 | long begin = System.currentTimeMillis(); 226 | featureMap = XGBoostUtil.loadFeatureMap(is); 227 | long end = System.currentTimeMillis(); 228 | 229 | logger.info("Parsed feature map in {} ms.", (end - begin)); 230 | } catch(Exception e){ 231 | logger.error("Failed to parse feature map", e); 232 | 233 | throw e; 234 | } 235 | } 236 | 237 | Map options = new LinkedHashMap<>(); 238 | options.put(HasXGBoostOptions.OPTION_MISSING, this.missing); 239 | options.put(HasXGBoostOptions.OPTION_COMPACT, this.compact); 240 | options.put(HasXGBoostOptions.OPTION_INPUT_FLOAT, this.inputFloat); 241 | options.put(HasXGBoostOptions.OPTION_NUMERIC, this.numeric); 242 | options.put(HasXGBoostOptions.OPTION_PRUNE, this.prune); 243 | options.put(HasXGBoostOptions.OPTION_NTREE_LIMIT, this.ntreeLimit); 244 | 245 | PMML pmml; 246 | 247 | try { 248 | logger.info("Converting learner to PMML.."); 249 | 250 | long begin = System.currentTimeMillis(); 251 | pmml = learner.encodePMML(options, this.targetName, this.targetCategories, featureMap); 252 | long end = System.currentTimeMillis(); 253 | 254 | logger.info("Converted learner to PMML in {} ms.", (end - begin)); 255 | } catch(Exception e){ 256 | logger.error("Failed to convert learner to PMML", e); 257 | 258 | throw e; 259 | } 260 | 261 | try(OutputStream os = new FileOutputStream(this.pmmlOutput)){ 262 | logger.info("Marshalling PMML.."); 263 | 264 | JAXBSerializer jaxbSerializer = new MetroJAXBSerializer(); 265 | 266 | long begin = System.currentTimeMillis(); 267 | jaxbSerializer.serializePretty(pmml, os); 268 | long end = System.currentTimeMillis(); 269 | 270 | logger.info("Marshalled PMML in {} ms.", (end - begin)); 271 | } catch(Exception e){ 272 | logger.error("Failed to marshal PMML", e); 273 | 274 | throw e; 275 | } 276 | } 277 | 278 | private static final Logger logger = LoggerFactory.getLogger(Main.class); 279 | } -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/csv/MultiLinearRegressionAutoNA.csv: -------------------------------------------------------------------------------- 1 | _target1,_target2 2 | 11.941184,17.4557 3 | 11.26842,14.64351 4 | 10.799914,17.604523 5 | 11.876421,16.139124 6 | 11.220784,17.336807 7 | 10.525966,15.181064 8 | 9.018423,14.182138 9 | 8.547223,13.930257 10 | 9.995613,13.74467 11 | 8.776045,14.536644 12 | 10.000971,15.006384 13 | 8.276157,14.164905 14 | 10.058548,15.095727 15 | 9.938011,14.032238 16 | 14.897948,24.096071 17 | 15.217191,22.144735 18 | 15.52358,18.418545 19 | 15.983752,20.746212 20 | 14.489856,26.96588 21 | 20.506138,26.238264 22 | 17.684395,25.553528 23 | 14.679434,24.114426 24 | 17.36304,25.142937 25 | 12.320756,25.842627 26 | 14.832964,20.849876 27 | 13.878356,10.163523 28 | 14.974892,10.690548 29 | 13.477215,11.074948 30 | 17.389471,10.089874 31 | 14.535026,27.964293 32 | 16.58601,27.109491 33 | 13.908213,25.026693 34 | 13.322897,19.59543 35 | 15.598912,16.232872 36 | 15.168733,18.136675 37 | 15.810962,18.840849 38 | 15.491971,17.94991 39 | 12.253614,14.354739 40 | 11.586526,13.754889 41 | 13.503472,13.946646 42 | 12.966947,14.093716 43 | 11.36135,11.979427 44 | 11.990528,13.057826 45 | 12.028267,13.040683 46 | 13.725668,18.226416 47 | 18.927307,22.509577 48 | 15.168733,18.136675 49 | 15.294306,18.058405 50 | 14.003216,22.87496 51 | 14.026649,27.94314 52 | 19.519732,30.075396 53 | 14.610378,30.011642 54 | 18.983852,31.102259 55 | 18.048676,34.67461 56 | 18.974371,26.939356 57 | 20.27875,26.326612 58 | 15.640113,23.664688 59 | 16.850767,25.012905 60 | 21.928139,24.856287 61 | 18.621435,20.550451 62 | 16.40124,22.132359 63 | 11.846471,13.225204 64 | 11.995426,13.883583 65 | 13.247111,15.068251 66 | 13.2024,14.163258 67 | 11.861669,16.839481 68 | 11.326623,11.251183 69 | 13.489582,13.0386915 70 | 13.26554,12.214745 71 | 12.449967,13.335735 72 | 13.459997,19.03001 73 | 12.973061,14.728983 74 | 13.949118,13.197114 75 | 15.595783,13.59161 76 | 13.858897,13.692308 77 | 14.398095,18.399006 78 | 17.92354,21.95728 79 | 18.68471,21.772732 80 | 17.988567,25.961052 81 | 16.705524,21.32101 82 | 17.943624,27.14148 83 | 14.916114,22.879723 84 | 15.880831,26.974983 85 | 16.91075,26.522333 86 | 12.469048,12.913618 87 | 11.623459,14.387386 88 | 13.068732,13.080806 89 | 14.385331,13.950225 90 | 12.261617,14.328812 91 | 11.528437,12.092914 92 | 12.18225,12.865974 93 | 13.027035,13.57971 94 | 14.04242,13.669116 95 | 12.021643,12.730514 96 | 11.018178,12.084643 97 | 11.168696,13.366019 98 | 16.527527,17.906668 99 | 17.60331,16.763037 100 | 15.839816,18.15058 101 | 16.544641,18.05419 102 | 15.955454,22.443583 103 | 21.0021,26.168354 104 | 13.995087,11.525282 105 | 12.503739,12.031578 106 | 12.789906,12.944522 107 | 12.584951,11.989076 108 | 15.1902685,18.003849 109 | 18.954397,20.331413 110 | 17.772026,24.602324 111 | 16.250755,22.301544 112 | 13.551811,18.081036 113 | 18.28766,19.306875 114 | 14.12273,20.997097 115 | 15.365755,25.55325 116 | 13.205381,14.760507 117 | 9.598956,15.880212 118 | 19.339025,28.91002 119 | 15.514743,23.827316 120 | 14.417413,21.048061 121 | 15.674501,19.458174 122 | 11.045902,14.858298 123 | 14.083314,23.683527 124 | 13.311736,19.79657 125 | 11.249562,11.28811 126 | 16.254343,19.863325 127 | 15.781325,18.484987 128 | 16.892296,15.520105 129 | 18.844229,30.783976 130 | 16.538261,26.13281 131 | 20.806938,31.586342 132 | 16.795773,24.870853 133 | 17.248343,16.027674 134 | 18.031725,16.033545 135 | 16.50195,18.322392 136 | 14.079615,15.772211 137 | 14.463585,13.043129 138 | 13.437311,14.050986 139 | 15.765828,14.074286 140 | 15.537703,14.006147 141 | 16.447912,28.768679 142 | 15.71069,26.415882 143 | 14.677013,26.009865 144 | 16.507254,31.027018 145 | 18.961761,31.905619 146 | 14.58161,27.995802 147 | 15.476051,24.340502 148 | 14.397625,26.01728 149 | 15.142021,24.206364 150 | 15.413433,25.97 151 | 16.139278,31.084024 152 | 16.673891,18.98555 153 | 16.233395,17.34819 154 | 20.873589,15.07036 155 | 19.60848,15.07036 156 | 11.543277,15.869482 157 | 14.033027,15.095763 158 | 14.382387,15.777915 159 | 13.739293,14.0259905 160 | 20.447542,17.24114 161 | 18.681702,16.332594 162 | 18.630562,15.465138 163 | 18.788315,17.837303 164 | 15.260718,20.611982 165 | 13.350841,19.845993 166 | 11.826528,13.436993 167 | 15.982659,29.054766 168 | 16.784056,22.682735 169 | 16.510765,19.443167 170 | 18.514193,22.80757 171 | 13.664766,23.969423 172 | 16.528717,25.173594 173 | 16.286654,24.013697 174 | 15.142816,18.22533 175 | 14.21163,29.329182 176 | 17.056347,18.800226 177 | 14.961467,22.994017 178 | 17.140707,23.398615 179 | 15.155548,21.894165 180 | 13.418851,25.150463 181 | 17.452412,33.007427 182 | 15.464989,27.77332 183 | 16.85175,25.444422 184 | 15.089841,25.065632 185 | 17.574314,25.954369 186 | 15.443436,27.651375 187 | 13.349543,17.043896 188 | 12.562342,15.342571 189 | 13.82818,15.869357 190 | 12.7210655,14.399903 191 | 15.61019,22.030804 192 | 15.276557,20.97523 193 | 17.612198,24.07337 194 | 17.183079,22.107153 195 | 22.221882,29.372711 196 | 22.09968,25.184334 197 | 14.263392,28.939098 198 | 17.243376,32.860188 199 | 17.50557,19.17195 200 | 20.587528,17.845709 201 | 16.389929,18.27984 202 | 17.533249,18.327515 203 | 12.4143095,29.601751 204 | 16.906664,31.960756 205 | 16.244707,27.810684 206 | 13.751129,26.222813 207 | 15.559092,20.093092 208 | 13.368055,13.074272 209 | 21.580757,19.061766 210 | 15.387653,20.081877 211 | 16.74558,16.65563 212 | 12.072927,16.156975 213 | 12.116064,13.369738 214 | 14.80921,13.281253 215 | 14.109525,13.359201 216 | 18.4416,32.006042 217 | 15.014525,29.404144 218 | 18.567709,35.858044 219 | 15.197996,25.304235 220 | 16.892897,33.8864 221 | 12.642481,17.342384 222 | 18.886385,17.097668 223 | 13.754137,15.626089 224 | 14.573951,15.1812315 225 | 16.518824,18.094933 226 | 17.000526,20.223978 227 | 17.369781,18.86373 228 | 18.714293,18.608423 229 | 11.103637,15.827972 230 | 11.425987,15.502322 231 | 12.22795,15.267808 232 | 14.1817465,15.7394 233 | 14.472426,28.908709 234 | 15.929995,24.639402 235 | 18.000496,26.553614 236 | 15.94965,24.803461 237 | 16.655626,31.139177 238 | 15.955378,33.24038 239 | 16.39552,30.963726 240 | 14.39582,29.96355 241 | 14.341659,22.5318 242 | 12.864719,21.631794 243 | 13.467198,21.68851 244 | 21.487892,42.285492 245 | 14.435198,35.934452 246 | 19.412477,32.88641 247 | 18.65098,38.972412 248 | 16.306845,36.000546 249 | 15.185755,20.946455 250 | 13.144783,19.751162 251 | 12.754647,19.76683 252 | 18.398441,19.325983 253 | 18.064764,20.496498 254 | 15.533575,20.551382 255 | 15.904172,24.600618 256 | 17.034134,20.515482 257 | 17.282553,19.534061 258 | 16.214478,20.706366 259 | 16.802446,20.67802 260 | 18.738192,18.6585 261 | 15.1469,18.0503 262 | 12.8567915,19.374138 263 | 13.515538,17.76224 264 | 11.499766,18.343588 265 | 13.790027,17.182014 266 | 16.524065,29.46539 267 | 14.286759,26.892668 268 | 15.018884,27.10113 269 | 14.628411,30.66663 270 | 14.859119,22.232664 271 | 16.77248,23.429901 272 | 17.871746,24.163843 273 | 15.133673,22.317797 274 | 15.802557,20.265263 275 | 13.791939,17.173847 276 | 15.335252,21.49892 277 | 15.664565,16.672499 278 | 14.877042,31.635101 279 | 16.516777,29.636026 280 | 15.368305,21.165474 281 | 17.844696,20.178232 282 | 17.091667,22.804222 283 | 18.212883,20.229912 284 | 16.132402,20.369095 285 | 15.443016,17.183395 286 | 13.877593,17.327934 287 | 13.35883,16.289291 288 | 15.184315,18.353342 289 | 15.032709,17.211 290 | 14.174878,15.36325 291 | 15.125444,19.181034 292 | 12.734985,17.962631 293 | 13.960833,31.950556 294 | 15.876208,34.419502 295 | 14.516765,35.47229 296 | 15.045425,27.60414 297 | 20.162308,25.400354 298 | 17.189514,21.945114 299 | 24.62463,27.038048 300 | 21.384472,23.497564 301 | 13.809885,33.951176 302 | 14.703021,34.55394 303 | 18.995476,32.111504 304 | 14.75128,37.302876 305 | 15.841224,28.577045 306 | 11.838897,28.48797 307 | 14.53322,24.921328 308 | 14.009253,31.393753 309 | 14.828956,40.446243 310 | 18.69207,36.9956 311 | 15.739699,32.777817 312 | 16.450165,37.727875 313 | 16.733835,27.703348 314 | 17.772026,24.602324 315 | 19.654709,24.863869 316 | 18.630537,19.735216 317 | 15.608821,34.692654 318 | 15.713439,29.935709 319 | 17.478643,31.534546 320 | 14.743564,35.908295 321 | 15.19488,32.50057 322 | 17.728666,45.40702 323 | 14.543332,28.0277 324 | 19.201763,41.396015 325 | 21.707657,44.36534 326 | 23.166714,41.764957 327 | 19.88634,35.71594 328 | 21.668768,29.77327 329 | 14.00564,43.59179 330 | 17.704123,34.011654 331 | 15.6941595,30.95382 332 | 11.761575,32.376446 333 | 12.527228,23.967817 334 | 15.220465,34.534054 335 | 16.716797,32.70197 336 | 15.58291,27.463755 337 | 16.358423,27.349525 338 | 14.200042,26.176807 339 | 13.113066,23.191753 340 | 13.280176,29.611164 341 | 16.920841,39.04426 342 | 16.416,38.84752 343 | 16.205845,35.60086 344 | 17.631634,32.690456 345 | 19.193115,36.767265 346 | 17.321012,37.66999 347 | 16.245142,33.999798 348 | 15.003573,34.26849 349 | 16.296526,33.255745 350 | 20.532263,30.146795 351 | 14.267292,32.91661 352 | 14.650203,33.138714 353 | 16.81911,32.444435 354 | 15.110928,32.448895 355 | 18.286512,31.587145 356 | 20.603077,27.958622 357 | 19.560406,30.238876 358 | 12.674049,25.567234 359 | 14.009273,23.530993 360 | 15.778485,22.758614 361 | 18.66795,26.609503 362 | 16.902643,20.672419 363 | 16.615713,17.996284 364 | 19.152788,28.06365 365 | 17.540356,26.625639 366 | 17.842638,34.131634 367 | 16.646431,30.851694 368 | 15.752249,29.933975 369 | 17.710823,26.90984 370 | 16.122515,23.94994 371 | 15.159906,35.72821 372 | 18.012436,36.833817 373 | 16.975574,31.722794 374 | 14.9321165,37.928864 375 | 17.071995,36.142754 376 | 14.688655,36.23077 377 | 14.534923,35.832882 378 | 16.839008,33.648617 379 | 15.4343195,34.946487 380 | 15.4343195,34.946487 381 | 16.198027,37.667942 382 | 15.539083,24.827377 383 | 17.054634,37.21868 384 | 14.480462,26.63236 385 | 14.796091,22.292076 386 | 14.334056,30.124596 387 | 13.477425,35.506504 388 | 17.392624,26.786633 389 | 15.769229,26.463114 390 | 24.347416,43.737373 391 | 12.364572,32.38904 392 | 17.628843,27.153889 393 | 18.805233,31.036932 394 | -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/csv/MultiLinearRegressionAuto.csv: -------------------------------------------------------------------------------- 1 | _target1,_target2 2 | 11.789928,17.29399 3 | 10.707663,13.817198 4 | 11.06097,16.597347 5 | 11.299117,16.722237 6 | 10.771538,16.89269 7 | 9.626912,14.01186 8 | 9.090639,13.666319 9 | 8.863352,13.666319 10 | 10.036789,13.238881 11 | 9.040234,14.400267 12 | 9.758257,15.210078 13 | 9.051154,14.396144 14 | 9.7854805,14.608622 15 | 9.862217,14.326501 16 | 15.3199625,24.511637 17 | 15.715048,21.62988 18 | 15.4454975,18.646936 19 | 15.664518,20.983128 20 | 15.154148,27.039865 21 | 20.568623,25.858528 22 | 17.200783,24.634933 23 | 15.021787,24.547373 24 | 16.55144,24.705206 25 | 12.468762,25.92538 26 | 15.44235,20.898762 27 | 13.443436,10.111436 28 | 14.784432,10.848039 29 | 13.472484,10.848039 30 | 17.886475,9.7157345 31 | 14.485303,27.645954 32 | 15.362589,26.694464 33 | 14.390272,25.5688 34 | 13.315647,18.830204 35 | 15.480244,17.244322 36 | 15.316078,17.702572 37 | 15.539824,17.968826 38 | 15.316078,17.876905 39 | 12.021141,13.700345 40 | 11.442532,13.106618 41 | 13.083147,13.697869 42 | 13.157269,13.621329 43 | 11.865057,11.743831 44 | 11.640077,12.684088 45 | 11.89919,12.673745 46 | 13.500599,17.937431 47 | 18.882168,22.688944 48 | 15.054198,17.702572 49 | 15.433967,17.82196 50 | 14.220533,23.677408 51 | 14.116654,27.239283 52 | 19.059814,30.078424 53 | 14.925389,29.98413 54 | 19.248156,32.046432 55 | 18.223963,34.423862 56 | 19.065245,27.187685 57 | 18.920738,26.425505 58 | 15.700714,24.379631 59 | 16.33256,26.125763 60 | 23.733904,22.799412 61 | 18.062426,20.663157 62 | 16.472954,21.347303 63 | 12.148955,13.229122 64 | 11.921485,13.155841 65 | 13.274934,14.028853 66 | 12.998687,13.582461 67 | 11.752827,15.069381 68 | 11.196736,11.408828 69 | 13.494941,12.520799 70 | 13.285277,12.4724045 71 | 12.127634,13.051736 72 | 13.805,19.099 73 | 12.592039,14.563531 74 | 14.433439,13.34024 75 | 15.567943,13.649934 76 | 13.531322,13.642102 77 | 14.661839,18.812243 78 | 17.880821,21.629004 79 | 19.467615,20.447535 80 | 17.770063,26.12565 81 | 17.336596,21.323751 82 | 16.91711,27.112864 83 | 14.624421,22.551525 84 | 15.948033,27.288908 85 | 16.31615,26.893732 86 | 12.285908,13.152913 87 | 11.671913,14.07419 88 | 12.960817,13.501886 89 | 14.546667,13.622193 90 | 12.208572,13.6615095 91 | 11.492603,11.380199 92 | 12.301042,12.734471 93 | 13.231976,12.988097 94 | 14.210229,13.470514 95 | 11.014496,12.49907 96 | 10.919479,12.247418 97 | 11.041137,13.098965 98 | 16.281,18.185013 99 | 17.4774,16.292917 100 | 15.86778,18.43062 101 | 16.811281,17.898832 102 | 16.1237,21.566044 103 | 21.263744,25.779638 104 | 13.732303,11.717891 105 | 12.286249,11.819723 106 | 12.914542,12.365956 107 | 12.808399,11.484598 108 | 15.198532,18.068563 109 | 18.09312,20.822393 110 | 19.357065,20.725475 111 | 16.356798,22.252472 112 | 13.510401,18.504541 113 | 17.563608,19.884474 114 | 14.120389,20.661625 115 | 15.988511,25.338182 116 | 13.136687,13.53445 117 | 9.9752,15.5451145 118 | 19.5084,28.832289 119 | 15.431945,23.962528 120 | 14.535426,20.556988 121 | 15.405786,19.492949 122 | 11.1412945,14.882327 123 | 14.006544,23.108318 124 | 13.460634,19.574097 125 | 10.927317,12.115418 126 | 16.636524,19.761515 127 | 16.003658,19.01894 128 | 16.752638,16.09877 129 | 18.23553,31.095068 130 | 16.457634,25.197813 131 | 20.388659,32.080452 132 | 16.788246,25.094643 133 | 17.219645,15.319278 134 | 17.59269,16.049517 135 | 16.696232,17.793169 136 | 14.430392,14.568694 137 | 14.376347,12.894865 138 | 14.012642,13.61022 139 | 15.885393,13.662828 140 | 15.336855,14.431425 141 | 15.814898,28.212046 142 | 16.32081,27.769005 143 | 15.442779,26.637526 144 | 16.626348,31.589373 145 | 18.987617,32.087296 146 | 15.069328,26.884623 147 | 15.053118,25.96208 148 | 14.434168,26.007242 149 | 14.736457,24.585335 150 | 15.831414,25.47846 151 | 16.381573,29.597595 152 | 16.61367,18.978462 153 | 16.276047,16.609947 154 | 20.903616,15.53398 155 | 19.580564,15.232778 156 | 11.544019,15.376407 157 | 13.839907,14.962692 158 | 14.059121,15.5984535 159 | 13.77903,14.509816 160 | 20.27784,16.758034 161 | 18.683435,16.32463 162 | 19.22976,15.481825 163 | 18.95717,17.767048 164 | 14.776749,19.72096 165 | 14.310638,19.344358 166 | 11.92573,14.177827 167 | 16.100613,28.780758 168 | 17.15243,23.444752 169 | 15.225742,19.433775 170 | 18.063341,23.193554 171 | 14.2878475,23.616623 172 | 16.063662,25.315493 173 | 15.831157,23.807066 174 | 15.216564,19.078957 175 | 14.336561,28.875696 176 | 16.757227,18.693794 177 | 15.224755,23.782072 178 | 16.966717,22.600815 179 | 14.716676,21.687317 180 | 13.403741,24.296751 181 | 17.51039,33.089577 182 | 15.86852,26.982603 183 | 16.389788,25.242659 184 | 14.968916,25.072042 185 | 16.995045,26.663258 186 | 15.39668,27.757198 187 | 13.080128,15.600005 188 | 13.085435,14.419382 189 | 14.423326,15.111639 190 | 12.919722,14.319032 191 | 15.7982645,21.005503 192 | 15.397802,19.894289 193 | 17.306625,23.977316 194 | 17.198456,21.696667 195 | 22.403866,29.12564 196 | 21.931265,24.85812 197 | 13.992891,29.067804 198 | 17.420597,33.141327 199 | 17.561174,19.855045 200 | 20.582891,18.18929 201 | 16.495256,18.277578 202 | 17.474876,18.669525 203 | 12.813712,29.490519 204 | 17.139482,31.705938 205 | 16.121164,27.972673 206 | 14.514996,26.268003 207 | 15.808429,20.085289 208 | 13.049859,13.876749 209 | 21.3486,19.653578 210 | 15.266349,19.964525 211 | 16.61354,16.478975 212 | 12.263094,15.257125 213 | 12.682029,13.845305 214 | 14.649165,14.119988 215 | 13.595439,13.823017 216 | 17.974699,31.292421 217 | 14.825127,30.225563 218 | 18.560635,35.68673 219 | 15.217565,25.52415 220 | 16.843523,33.443996 221 | 13.10124,16.661179 222 | 18.844183,17.09831 223 | 13.425851,15.591122 224 | 14.922553,15.130587 225 | 16.370846,17.795033 226 | 16.713724,20.011238 227 | 17.953514,19.401302 228 | 18.761063,18.430443 229 | 10.985044,15.770439 230 | 11.961445,15.419653 231 | 11.893997,15.630963 232 | 14.1729145,15.401007 233 | 14.471932,30.217861 234 | 15.906046,24.711586 235 | 17.744884,26.556707 236 | 15.887286,24.91665 237 | 16.999722,31.105478 238 | 15.792761,32.522232 239 | 16.57981,30.241428 240 | 15.105264,30.038277 241 | 14.514641,21.693453 242 | 12.9049425,22.086681 243 | 13.499581,21.423672 244 | 21.367887,41.985435 245 | 14.43115,36.01557 246 | 19.465378,33.390194 247 | 18.37843,39.462257 248 | 16.411108,36.56777 249 | 15.644352,19.804092 250 | 13.195518,18.6846 251 | 12.7082,19.367033 252 | 18.827406,19.164415 253 | 17.518747,20.15802 254 | 16.530897,20.523212 255 | 15.740761,24.941023 256 | 17.19669,19.604837 257 | 17.518747,19.761225 258 | 16.013567,19.710573 259 | 16.864935,20.70574 260 | 18.788717,18.599472 261 | 14.934468,18.068003 262 | 12.920134,19.12194 263 | 13.479801,17.624397 264 | 11.42784,18.291967 265 | 13.635156,17.827057 266 | 16.333977,30.637236 267 | 14.528812,26.043974 268 | 14.834935,26.583164 269 | 14.520244,29.760662 270 | 14.647772,23.036455 271 | 16.077076,23.259373 272 | 17.091684,23.556393 273 | 14.876448,24.409304 274 | 15.745906,20.704828 275 | 14.047313,17.080587 276 | 15.565529,21.234518 277 | 15.663549,16.84773 278 | 14.953351,31.428875 279 | 16.898527,30.637236 280 | 15.033221,21.493952 281 | 18.112633,20.08178 282 | 17.537014,22.93097 283 | 18.346256,20.804169 284 | 16.829023,20.83601 285 | 15.088701,17.282877 286 | 13.944803,17.282877 287 | 13.569522,16.749575 288 | 15.100012,17.82019 289 | 14.727014,16.7692 290 | 13.801515,16.11906 291 | 14.916452,19.847095 292 | 13.415841,18.17876 293 | 14.0327635,32.311996 294 | 16.146143,33.940777 295 | 14.165419,35.950584 296 | 15.409086,28.290117 297 | 20.277159,25.338533 298 | 16.732342,21.702473 299 | 24.156801,27.13306 300 | 21.505894,23.366701 301 | 13.875596,34.68552 302 | 14.345798,34.68552 303 | 18.805292,33.222256 304 | 15.170669,37.634056 305 | 15.730882,27.82972 306 | 11.70019,28.053587 307 | 12.770599,27.352865 308 | 13.917676,32.488914 309 | 15.1275215,39.72467 310 | 18.437723,37.94075 311 | 15.915453,33.150543 312 | 16.623474,38.869198 313 | 16.37116,27.735651 314 | 18.060738,25.567709 315 | 19.561567,25.012379 316 | 18.657743,19.632282 317 | 15.393068,35.281788 318 | 15.729466,30.717167 319 | 17.315968,31.687508 320 | 14.649403,36.43925 321 | 15.589378,32.96545 322 | 17.54068,44.18413 323 | 14.497501,27.680798 324 | 19.254005,41.802258 325 | 22.18706,45.36466 326 | 23.76997,43.492794 327 | 19.89374,36.026863 328 | 22.04166,30.208572 329 | 14.467306,41.164272 330 | 17.20503,35.51642 331 | 15.374552,33.027966 332 | 11.378779,31.713747 333 | 12.648914,24.073172 334 | 15.251958,34.874 335 | 16.526018,32.794846 336 | 15.531388,28.00549 337 | 16.340897,26.978518 338 | 14.70454,26.147787 339 | 13.006514,23.941078 340 | 13.25619,29.69585 341 | 16.824245,39.56169 342 | 16.273697,38.924355 343 | 16.257036,35.531685 344 | 17.229567,32.887238 345 | 18.865696,37.352867 346 | 17.080896,37.597755 347 | 16.60891,34.500645 348 | 15.204381,34.800144 349 | 16.98347,34.41864 350 | 20.386011,30.349127 351 | 14.0014305,33.420563 352 | 14.568964,33.984474 353 | 16.96274,32.20148 354 | 14.579982,32.84259 355 | 18.227713,31.653093 356 | 20.446484,28.337364 357 | 19.611084,29.80623 358 | 12.823285,25.405113 359 | 13.330807,24.74095 360 | 15.915157,22.080896 361 | 18.753736,26.56323 362 | 16.874025,19.930931 363 | 16.951426,18.127098 364 | 18.697657,28.027733 365 | 18.459501,27.897001 366 | 17.738613,34.432148 367 | 16.52312,31.140316 368 | 15.651647,30.325342 369 | 17.082802,27.461853 370 | 16.137253,25.02496 371 | 15.067095,36.220295 372 | 17.74395,37.023758 373 | 16.943762,32.447914 374 | 15.277944,38.422447 375 | 17.405289,36.519917 376 | 14.612832,36.063 377 | 14.7281065,35.89541 378 | 16.63338,33.64376 379 | 15.997988,35.891365 380 | 15.997988,35.891365 381 | 16.074635,37.63454 382 | 15.874717,25.377813 383 | 16.99028,36.731625 384 | 14.451713,26.519075 385 | 14.966574,22.338993 386 | 14.248887,31.27402 387 | 12.988419,34.984234 388 | 17.617641,25.895987 389 | 16.510603,26.82925 390 | 23.78599,43.652348 391 | 12.8693905,33.160847 392 | 18.676195,28.12166 393 | 18.955685,29.612036 394 | -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/csv/MultiRandomForestAutoNA.csv: -------------------------------------------------------------------------------- 1 | _target1,_target2 2 | 14.681749,20.923298 3 | 14.416093,20.923836 4 | 14.606725,21.030027 5 | 14.661179,20.816673 6 | 15.484212,21.510757 7 | 14.524478,20.943914 8 | 14.311396,20.94714 9 | 14.328708,20.677036 10 | 14.311396,20.740616 11 | 14.39045,20.679075 12 | 14.3511305,20.703518 13 | 14.428498,20.88176 14 | 14.596434,20.837563 15 | 14.302868,20.826242 16 | 15.496598,23.650103 17 | 15.678788,23.306234 18 | 15.513143,22.343508 19 | 15.601967,22.783083 20 | 15.618291,24.237268 21 | 16.94309,25.028004 22 | 15.845724,24.198254 23 | 15.614388,23.760172 24 | 15.652557,24.035227 25 | 15.030108,23.86669 26 | 15.552624,22.723696 27 | 14.690167,20.677036 28 | 15.015774,20.693392 29 | 14.781122,20.740616 30 | 15.547701,20.839602 31 | 15.690291,25.142595 32 | 15.900565,24.006592 33 | 15.495373,24.024584 34 | 15.663056,22.95676 35 | 15.71436,21.993092 36 | 15.501207,22.276442 37 | 15.832375,22.270416 38 | 15.579152,22.077732 39 | 14.495281,20.727652 40 | 14.393322,20.677036 41 | 14.9162655,20.677036 42 | 14.837622,20.894218 43 | 14.373987,20.679075 44 | 14.386296,20.677036 45 | 14.43781,20.677036 46 | 15.471444,22.177307 47 | 15.80158,23.606585 48 | 15.501207,22.276442 49 | 15.960319,22.174395 50 | 15.701347,23.43006 51 | 15.648797,24.53557 52 | 16.062685,25.032019 53 | 15.709161,24.739708 54 | 16.15848,25.466225 55 | 15.968452,25.69898 56 | 16.346626,24.982634 57 | 15.953008,24.351908 58 | 15.55514,23.55388 59 | 15.910324,24.045132 60 | 15.989002,24.137352 61 | 15.813657,23.125198 62 | 15.767125,23.94486 63 | 14.490705,20.740616 64 | 14.402371,20.740616 65 | 14.834009,20.837563 66 | 14.880114,20.87527 67 | 14.812875,21.092093 68 | 14.915096,20.836624 69 | 14.853618,20.834585 70 | 14.561429,20.677036 71 | 14.377091,20.727652 72 | 15.062293,22.72705 73 | 14.860345,20.704468 74 | 15.06111,20.86512 75 | 15.416404,20.781042 76 | 14.856509,20.834585 77 | 15.31498,22.544836 78 | 15.796903,23.341227 79 | 15.9085,23.508772 80 | 15.846517,24.274685 81 | 15.804401,23.076145 82 | 15.972003,24.17205 83 | 15.533257,23.373817 84 | 15.905958,24.125322 85 | 15.9230175,23.863075 86 | 14.482922,20.679075 87 | 14.520981,20.73095 88 | 14.728992,20.677036 89 | 15.019952,20.834585 90 | 14.520981,20.679075 91 | 14.586352,20.834585 92 | 14.6739,20.677036 93 | 14.729861,20.923836 94 | 14.813164,20.677036 95 | 14.972082,20.839602 96 | 14.326457,20.727652 97 | 14.4762945,20.679075 98 | 15.785827,21.921917 99 | 16.0686,22.066282 100 | 15.569974,22.144085 101 | 15.821045,22.183958 102 | 15.565308,22.941904 103 | 16.954357,24.192856 104 | 14.867048,20.740616 105 | 14.40289,20.677036 106 | 14.586352,20.834585 107 | 14.760007,20.939177 108 | 15.487769,22.47666 109 | 15.739698,23.263868 110 | 15.873359,23.969172 111 | 15.493924,23.208864 112 | 15.058104,22.66842 113 | 15.728113,22.995869 114 | 15.405793,22.68216 115 | 15.615347,23.352951 116 | 14.8031225,21.046074 117 | 14.31983,20.727652 118 | 16.05953,25.470594 119 | 15.691636,23.824457 120 | 15.501471,24.059967 121 | 15.683006,22.797064 122 | 14.699226,20.913446 123 | 15.454128,23.366833 124 | 14.96069,22.532482 125 | 14.580107,20.72969 126 | 15.578679,22.284527 127 | 15.570432,22.287664 128 | 16.010506,21.923855 129 | 15.968699,25.60269 130 | 15.778287,24.51925 131 | 16.19384,25.356863 132 | 15.633023,23.895264 133 | 16.051756,21.883335 134 | 16.014376,21.681576 135 | 15.737097,21.967133 136 | 15.143226,20.748636 137 | 15.205203,20.828032 138 | 15.037174,21.174171 139 | 15.454906,20.781042 140 | 15.467444,20.839602 141 | 15.670296,24.531929 142 | 15.888939,24.368132 143 | 15.677865,24.41501 144 | 15.835671,25.60269 145 | 16.256598,25.677515 146 | 15.644649,24.770962 147 | 15.704799,24.176094 148 | 15.676134,24.32956 149 | 15.51821,23.574942 150 | 15.524365,23.819582 151 | 15.699264,25.677515 152 | 16.138529,22.137444 153 | 16.213053,21.909256 154 | 16.032948,22.066986 155 | 16.046787,22.00287 156 | 14.492836,20.780743 157 | 15.066798,20.711412 158 | 15.146388,20.711412 159 | 14.9188595,20.727652 160 | 16.1541,21.949238 161 | 16.216986,21.932001 162 | 16.205048,21.73722 163 | 16.135025,21.989964 164 | 15.721112,22.093618 165 | 15.091525,22.054617 166 | 14.723756,20.849354 167 | 15.835669,24.895842 168 | 15.867313,23.46567 169 | 15.797698,22.083645 170 | 16.000477,23.42258 171 | 15.501471,23.823782 172 | 15.822627,23.875124 173 | 15.565655,23.366875 174 | 15.633764,22.381657 175 | 15.795729,25.880693 176 | 16.171707,22.096716 177 | 15.705523,23.37822 178 | 15.924739,23.495678 179 | 15.754509,23.084206 180 | 15.174098,23.687164 181 | 15.983386,25.517105 182 | 15.74909,24.256872 183 | 15.866011,24.19606 184 | 15.563007,24.034344 185 | 15.897477,24.113808 186 | 15.751273,24.551472 187 | 15.006069,21.05521 188 | 15.011929,21.047798 189 | 15.0544615,21.366737 190 | 14.7562685,20.677036 191 | 15.638789,22.592575 192 | 15.984697,22.196228 193 | 15.960319,23.446468 194 | 15.929317,22.414173 195 | 17.025051,25.60269 196 | 16.769594,24.796284 197 | 15.750109,24.876282 198 | 15.728272,25.11564 199 | 16.069155,21.927557 200 | 15.931168,22.468855 201 | 15.718873,22.282127 202 | 16.020077,22.172487 203 | 15.677611,26.07601 204 | 15.794969,25.674059 205 | 15.798104,24.531082 206 | 15.797976,24.13725 207 | 15.766801,22.819258 208 | 14.847141,20.677036 209 | 16.420866,22.796125 210 | 15.514824,23.178516 211 | 15.596712,22.109201 212 | 14.576383,20.8933 213 | 14.791438,20.94285 214 | 15.270822,20.792288 215 | 14.975186,20.679075 216 | 15.746021,26.600212 217 | 15.631621,25.27201 218 | 16.342762,26.789986 219 | 15.461282,23.772976 220 | 16.010517,26.30697 221 | 14.813009,21.293758 222 | 16.027786,21.723213 223 | 14.979673,21.426865 224 | 15.163333,20.945953 225 | 15.999225,21.87648 226 | 15.940615,22.119982 227 | 16.027786,22.03074 228 | 16.18359,22.089235 229 | 14.641843,21.081528 230 | 14.560943,20.900059 231 | 14.377091,20.727652 232 | 15.003638,20.87527 233 | 15.67949,25.84231 234 | 15.7828,23.689587 235 | 15.700605,24.645807 236 | 15.766495,23.8938 237 | 15.856128,26.700844 238 | 15.862194,25.724451 239 | 15.778005,26.81465 240 | 15.687318,25.046547 241 | 15.501617,22.58764 242 | 15.414773,23.2373 243 | 15.048605,23.198591 244 | 16.938951,26.961327 245 | 15.637667,26.964481 246 | 16.635067,27.036766 247 | 16.103418,26.354427 248 | 15.893281,27.036766 249 | 15.759667,22.061138 250 | 14.897429,22.237123 251 | 14.728755,22.006153 252 | 16.02589,22.053823 253 | 16.129139,22.21761 254 | 15.646607,22.639818 255 | 15.77064,23.830694 256 | 15.646534,22.27221 257 | 16.143225,22.172825 258 | 15.725633,22.249853 259 | 15.960319,22.378403 260 | 16.09608,22.197603 261 | 15.4120455,22.088396 262 | 14.730681,21.96758 263 | 14.948083,21.785574 264 | 14.684262,21.906244 265 | 14.909342,21.784613 266 | 15.780486,25.30297 267 | 15.4966545,23.662619 268 | 15.636063,24.778502 269 | 15.609655,25.418406 270 | 15.4809265,23.584211 271 | 15.632656,23.462513 272 | 15.74677,23.929857 273 | 15.549405,22.576752 274 | 15.513594,22.934345 275 | 15.102974,22.176842 276 | 15.349323,23.08728 277 | 15.502484,22.169838 278 | 15.714573,25.813955 279 | 15.709979,26.367346 280 | 15.51593,22.286037 281 | 15.698079,22.90587 282 | 15.609767,24.271442 283 | 15.947891,22.470203 284 | 15.853933,22.231041 285 | 15.382568,21.47344 286 | 15.112381,21.34722 287 | 14.917898,20.973608 288 | 15.419569,21.896671 289 | 15.530674,21.295084 290 | 15.124765,21.13352 291 | 15.387797,22.061062 292 | 14.684098,21.04576 293 | 15.557865,26.431639 294 | 15.882074,27.066826 295 | 15.684315,26.095974 296 | 15.625924,24.70943 297 | 15.934982,24.108192 298 | 15.945182,21.970213 299 | 16.616974,24.39553 300 | 16.310156,22.659325 301 | 15.730648,26.119406 302 | 15.608985,26.503101 303 | 16.064665,26.148676 304 | 15.689532,26.898205 305 | 15.636583,24.630684 306 | 15.514698,24.55584 307 | 15.853933,23.544836 308 | 15.622724,24.777906 309 | 15.75126,26.646526 310 | 16.674442,26.78773 311 | 15.788316,26.889654 312 | 15.926238,27.220781 313 | 15.720432,24.752766 314 | 15.873359,23.969172 315 | 16.027767,24.371105 316 | 16.257862,22.67446 317 | 15.753592,26.106588 318 | 15.740983,24.767078 319 | 15.777179,25.728138 320 | 15.524069,25.806776 321 | 15.869444,26.23087 322 | 15.973311,27.24084 323 | 15.570085,24.524506 324 | 16.15976,27.086885 325 | 16.97456,27.24084 326 | 15.854369,25.815157 327 | 16.043612,25.933403 328 | 16.534084,24.90528 329 | 15.690473,27.066826 330 | 15.822294,26.816147 331 | 16.038925,26.78773 332 | 14.839832,24.739061 333 | 14.993182,23.92833 334 | 15.798191,25.042223 335 | 15.842637,25.416327 336 | 15.71383,24.658789 337 | 15.7242985,25.158594 338 | 15.59316,23.92009 339 | 15.6261,23.263433 340 | 15.691359,24.927347 341 | 16.215168,26.78773 342 | 15.9127035,27.030027 343 | 15.855292,27.220781 344 | 15.874557,26.318562 345 | 16.147028,27.220781 346 | 15.965915,27.093931 347 | 15.762293,26.807926 348 | 15.853831,26.25861 349 | 15.856128,26.700844 350 | 16.050402,25.770342 351 | 15.667875,26.093374 352 | 15.806954,25.57464 353 | 15.724992,25.998405 354 | 15.756179,25.206903 355 | 15.724992,25.697453 356 | 16.438011,24.589844 357 | 16.228722,24.719046 358 | 14.910914,23.745396 359 | 15.177786,23.154545 360 | 15.620973,22.527557 361 | 15.846071,23.365118 362 | 15.840553,22.534708 363 | 16.12187,22.354267 364 | 15.717826,25.08553 365 | 15.74677,24.18422 366 | 15.714629,25.807695 367 | 15.730648,24.905325 368 | 15.730644,24.817474 369 | 15.909509,24.00952 370 | 15.58522,24.239325 371 | 15.728782,26.280188 372 | 15.708133,26.935524 373 | 15.778005,26.837894 374 | 15.717744,27.075031 375 | 15.737011,26.858189 376 | 15.692158,26.093185 377 | 15.70332,26.209913 378 | 15.664217,24.821648 379 | 15.701759,27.220781 380 | 15.701759,27.220781 381 | 15.778005,27.066826 382 | 15.538225,23.367073 383 | 15.829876,25.06884 384 | 15.501057,24.533085 385 | 15.67151,23.371696 386 | 15.492448,24.14456 387 | 15.634828,25.889868 388 | 15.865832,24.495317 389 | 15.70529,24.420671 390 | 17.018393,27.157372 391 | 15.671196,25.867718 392 | 15.730648,24.594404 393 | 15.74273,25.703592 394 | -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/csv/MultiRandomForestAuto.csv: -------------------------------------------------------------------------------- 1 | _target1,_target2 2 | 14.515312,20.978846 3 | 14.399624,20.69972 4 | 14.472935,20.831755 5 | 14.472935,20.831755 6 | 14.484836,20.898172 7 | 14.20991,20.630348 8 | 14.20991,20.630348 9 | 14.20991,20.630348 10 | 14.266835,20.630348 11 | 14.204959,20.677696 12 | 14.204959,20.867094 13 | 14.399624,20.747904 14 | 14.357721,20.677696 15 | 14.204959,20.9148 16 | 15.466679,23.819677 17 | 15.54961,22.66608 18 | 15.526059,22.423773 19 | 15.682019,22.598444 20 | 15.634466,24.279867 21 | 17.00509,24.144464 22 | 15.7880125,23.864916 23 | 15.619746,23.88822 24 | 15.529505,23.852415 25 | 14.798981,23.966333 26 | 15.648903,22.545137 27 | 14.8203125,20.630348 28 | 15.192823,20.630348 29 | 14.987766,20.630348 30 | 15.755352,20.630348 31 | 15.679897,24.575378 32 | 15.598502,23.95418 33 | 15.338813,23.909882 34 | 15.185315,22.327333 35 | 15.616357,21.881449 36 | 15.599097,21.785055 37 | 15.678499,21.79769 38 | 15.604053,21.919743 39 | 14.662488,20.630348 40 | 14.281663,20.630348 41 | 14.838804,20.630348 42 | 14.830802,20.630348 43 | 14.342653,20.630348 44 | 14.281663,20.630348 45 | 14.342653,20.630348 46 | 15.288153,22.200314 47 | 15.84676,23.469814 48 | 15.57595,21.785055 49 | 15.672013,21.81517 50 | 15.618061,23.904993 51 | 15.552943,24.355001 52 | 16.035807,25.36929 53 | 15.661574,25.006193 54 | 16.267237,25.591585 55 | 16.037264,25.591585 56 | 16.49928,25.224005 57 | 15.782607,25.20612 58 | 15.445413,23.498434 59 | 15.688914,24.441313 60 | 16.939112,23.485388 61 | 15.817464,22.994682 62 | 15.711904,23.20396 63 | 14.712946,20.630348 64 | 14.289863,20.630348 65 | 14.873708,20.630348 66 | 14.8488455,20.630348 67 | 14.617355,20.69972 68 | 14.289863,20.630348 69 | 14.91244,20.630348 70 | 14.762231,20.630348 71 | 14.289863,20.630348 72 | 15.210899,22.53986 73 | 14.846793,20.677696 74 | 15.020693,20.884922 75 | 15.3194895,20.669632 76 | 14.873708,20.630348 77 | 15.401261,22.642202 78 | 15.869463,23.066471 79 | 16.227596,22.772383 80 | 15.835818,23.9642 81 | 15.839426,22.994682 82 | 15.503066,23.926672 83 | 15.417014,23.160425 84 | 15.684818,24.454746 85 | 15.699516,24.302046 86 | 14.6736355,20.630348 87 | 14.506956,20.69972 88 | 14.785576,20.643038 89 | 15.099459,20.696358 90 | 14.584433,20.677696 91 | 14.299882,20.630348 92 | 14.502953,20.630348 93 | 14.863362,20.630348 94 | 14.895982,20.630348 95 | 14.281663,20.630348 96 | 14.299882,20.630348 97 | 14.505924,20.677696 98 | 15.755203,21.974842 99 | 15.849825,21.80938 100 | 15.539893,22.24056 101 | 15.966031,22.220537 102 | 15.563444,22.636425 103 | 17.095364,24.143196 104 | 14.580791,20.630348 105 | 14.361305,20.630348 106 | 14.686643,20.630348 107 | 14.7073345,20.630348 108 | 15.529418,22.24056 109 | 15.709899,23.420605 110 | 15.883159,23.007744 111 | 15.467888,23.254492 112 | 15.386341,22.533028 113 | 15.714985,22.959513 114 | 15.368265,22.500227 115 | 15.652792,23.497383 116 | 14.810087,20.643038 117 | 14.239726,20.630348 118 | 16.916075,24.955975 119 | 15.693744,23.639269 120 | 15.410941,23.073286 121 | 15.371185,22.676056 122 | 14.506956,20.898619 123 | 15.322866,23.057257 124 | 14.860228,22.412231 125 | 14.414612,20.69972 126 | 15.8343935,22.408554 127 | 15.539997,22.312065 128 | 15.859066,21.807447 129 | 16.053555,25.575214 130 | 15.714836,23.9299 131 | 16.26203,25.575214 132 | 15.758699,23.913628 133 | 16.106266,21.679247 134 | 16.07765,21.721827 135 | 16.047834,21.881449 136 | 15.1688595,20.669632 137 | 15.219942,20.630348 138 | 15.161122,20.630348 139 | 15.426476,20.669632 140 | 15.293538,20.630348 141 | 15.604998,24.564331 142 | 15.992753,25.398283 143 | 15.596352,24.24509 144 | 15.909647,25.592009 145 | 16.38315,25.552727 146 | 15.597197,24.568676 147 | 15.588261,24.52945 148 | 15.582157,24.105463 149 | 15.436123,23.805353 150 | 15.479118,23.984432 151 | 15.992753,25.418344 152 | 15.902473,21.945671 153 | 15.929336,21.751493 154 | 16.751415,21.764128 155 | 16.616873,21.81517 156 | 14.327124,20.736917 157 | 14.98403,20.749607 158 | 14.982651,20.736917 159 | 14.98403,20.736917 160 | 16.22537,21.8193 161 | 16.234238,21.697271 162 | 16.234238,21.729261 163 | 16.275614,21.831934 164 | 15.7071,22.259031 165 | 15.548972,22.017323 166 | 14.733274,20.991982 167 | 15.695173,24.633862 168 | 15.895571,23.568335 169 | 15.505707,22.228767 170 | 15.889881,23.568335 171 | 15.411914,23.602741 172 | 15.678829,23.997437 173 | 15.431581,23.624714 174 | 15.654071,22.431793 175 | 15.649379,25.37185 176 | 16.13131,21.932377 177 | 15.425736,23.624714 178 | 15.988751,23.174654 179 | 15.453201,23.007343 180 | 15.007955,23.587448 181 | 16.040182,25.580824 182 | 15.71568,24.073545 183 | 15.628433,23.902786 184 | 15.485624,23.764896 185 | 15.635748,24.136595 186 | 15.623322,24.564352 187 | 14.880414,20.693155 188 | 14.842426,20.653872 189 | 15.151026,21.373697 190 | 14.827853,20.653872 191 | 15.790181,22.231478 192 | 15.770565,22.053396 193 | 15.986512,23.181894 194 | 15.987322,22.715738 195 | 17.122446,25.373163 196 | 16.824566,24.131441 197 | 15.565727,25.42411 198 | 16.02056,25.633085 199 | 16.09552,22.13449 200 | 16.688488,21.997505 201 | 16.064789,21.959864 202 | 15.949506,22.056044 203 | 15.510669,25.05033 204 | 15.99249,25.608294 205 | 15.641437,24.712366 206 | 15.738651,23.836332 207 | 15.787765,22.59912 208 | 14.842426,20.677696 209 | 16.485348,22.764694 210 | 15.467177,22.58116 211 | 15.65376,22.027218 212 | 14.745008,20.653872 213 | 14.839629,20.666561 214 | 15.167682,20.828714 215 | 14.852197,20.677696 216 | 15.803577,25.698862 217 | 15.597479,25.160488 218 | 16.295315,25.830118 219 | 15.350985,23.946848 220 | 15.99243,25.878962 221 | 14.820328,20.946127 222 | 16.226488,21.800106 223 | 14.883325,20.80694 224 | 15.3076105,20.917841 225 | 15.954511,21.867779 226 | 15.930598,22.11128 227 | 16.211256,21.989807 228 | 16.288784,21.867779 229 | 14.256334,20.79425 230 | 14.726679,20.79425 231 | 14.256334,20.79425 232 | 14.9863205,20.79425 233 | 15.565338,25.307463 234 | 15.739507,23.7455 235 | 15.666918,24.609488 236 | 15.752652,23.756386 237 | 15.823888,25.620909 238 | 15.630116,25.460007 239 | 15.82156,25.735678 240 | 15.632062,25.256098 241 | 15.316247,22.885786 242 | 15.190018,23.661423 243 | 15.056899,22.89497 244 | 17.05217,27.184778 245 | 15.57299,26.905611 246 | 16.585968,27.125217 247 | 16.004961,27.059057 248 | 15.842718,27.178194 249 | 15.687734,22.024675 250 | 14.818898,21.806824 251 | 14.78468,21.891924 252 | 16.144325,22.059372 253 | 15.881372,22.19858 254 | 15.856815,22.470865 255 | 15.786632,23.749098 256 | 15.899641,22.118887 257 | 15.962175,22.139803 258 | 15.77248,22.118887 259 | 15.940893,22.457783 260 | 16.184242,22.059372 261 | 15.377196,21.970905 262 | 14.762076,21.877356 263 | 15.108947,21.844397 264 | 14.705055,21.867188 265 | 14.910469,21.681492 266 | 15.684995,26.578434 267 | 15.411124,23.789268 268 | 15.443882,23.957407 269 | 15.604848,24.980476 270 | 15.420025,23.759111 271 | 15.50682,23.573917 272 | 15.795069,23.332663 273 | 15.428815,23.770124 274 | 15.466173,22.936481 275 | 15.271929,22.111193 276 | 15.272586,23.057194 277 | 15.531484,21.951614 278 | 15.620525,25.897898 279 | 15.713461,26.71365 280 | 15.441393,22.704386 281 | 16.042715,22.884941 282 | 15.776429,23.759756 283 | 16.229149,22.705608 284 | 15.816479,22.63554 285 | 15.318956,21.818233 286 | 15.252331,21.804379 287 | 15.058891,21.804396 288 | 15.298805,21.783377 289 | 15.193935,21.615074 290 | 15.058891,21.627764 291 | 15.398853,22.509003 292 | 15.04699,21.754261 293 | 15.480698,26.446276 294 | 15.819138,27.128164 295 | 15.48335,26.3386 296 | 15.701131,24.863224 297 | 16.869467,23.99107 298 | 15.700719,22.938389 299 | 16.875835,24.497965 300 | 16.484226,22.891933 301 | 15.565116,26.75063 302 | 15.572523,26.946413 303 | 16.173504,27.128164 304 | 15.624991,27.097805 305 | 15.60686,24.800913 306 | 14.879512,24.469494 307 | 14.879512,24.341536 308 | 15.588411,25.34199 309 | 15.63983,26.649015 310 | 16.355658,27.285904 311 | 15.719836,27.009031 312 | 15.93805,27.285904 313 | 15.737822,24.779163 314 | 15.877043,24.104048 315 | 16.293455,24.19541 316 | 16.328852,22.57199 317 | 15.648717,26.541113 318 | 15.704467,25.328829 319 | 15.827328,25.786898 320 | 15.3901615,26.07005 321 | 15.686301,26.333895 322 | 15.93805,27.285904 323 | 15.387407,24.429934 324 | 16.253294,27.285904 325 | 17.105879,27.285904 326 | 17.127958,26.761452 327 | 16.284786,25.959555 328 | 16.925062,25.055418 329 | 15.699415,27.219671 330 | 15.793641,27.15753 331 | 15.86889,27.221973 332 | 14.699611,24.387917 333 | 15.105469,23.926365 334 | 15.795064,25.881447 335 | 15.673476,26.333895 336 | 15.71925,25.599596 337 | 15.77141,24.651678 338 | 15.343552,24.47043 339 | 15.12046,23.789534 340 | 15.680734,25.88579 341 | 15.932597,27.219759 342 | 15.8566675,27.2169 343 | 15.899003,27.27932 344 | 15.810986,27.15753 345 | 16.234829,27.285904 346 | 15.890946,27.285904 347 | 15.810986,27.21366 348 | 15.728855,26.800238 349 | 15.867667,27.081276 350 | 15.9892435,26.239712 351 | 15.587069,26.501537 352 | 15.6137,26.49199 353 | 15.639901,26.26869 354 | 15.259551,25.266161 355 | 15.804324,25.531681 356 | 16.79753,24.539165 357 | 16.749367,24.307953 358 | 14.808249,24.112965 359 | 14.855871,24.03281 360 | 15.807892,22.65038 361 | 16.118967,23.550177 362 | 16.000616,22.824747 363 | 16.22454,22.48355 364 | 15.896266,25.16864 365 | 15.896266,25.12602 366 | 15.838895,26.068079 367 | 15.861382,25.60913 368 | 15.840772,25.543728 369 | 15.817465,24.60561 370 | 15.5350895,24.059011 371 | 15.6699295,26.662798 372 | 15.807735,27.21366 373 | 15.807735,27.21366 374 | 15.8378725,27.081276 375 | 15.767972,27.009031 376 | 15.67739,26.29924 377 | 15.675693,26.592436 378 | 15.766133,26.659977 379 | 15.796968,27.255545 380 | 15.796968,27.255545 381 | 15.807735,27.255545 382 | 15.505064,23.915667 383 | 15.897655,25.308155 384 | 15.472653,24.5364 385 | 15.478928,23.421076 386 | 15.401585,25.002481 387 | 15.710475,26.179518 388 | 15.89031,24.268976 389 | 15.871545,24.395567 390 | 17.141392,27.18789 391 | 15.698987,26.179518 392 | 15.896266,25.138094 393 | 15.896266,25.10698 394 | -------------------------------------------------------------------------------- /pmml-xgboost/src/test/resources/csv/MultinomialClassificationIris.csv: -------------------------------------------------------------------------------- 1 | _target,probability(0),probability(1),probability(2) 2 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 3 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 4 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 5 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 6 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 7 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 8 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 9 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 10 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 11 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 12 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 13 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 14 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 15 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 16 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 17 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 18 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 19 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 20 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 21 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 22 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 23 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 24 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 25 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 26 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 27 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 28 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 29 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 30 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 31 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 32 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 33 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 34 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 35 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 36 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 37 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 38 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 39 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 40 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 41 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 42 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 43 | 0,0.9665156602859497,0.016468649730086327,0.017015712335705757 44 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 45 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 46 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 47 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 48 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 49 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 50 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 51 | 0,0.9685237407684326,0.0165028665214777,0.014973331242799759 52 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 53 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 54 | 1,0.013431635685265064,0.9212871789932251,0.06528116762638092 55 | 1,0.014934414997696877,0.967819333076477,0.017246220260858536 56 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 57 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 58 | 1,0.02034630998969078,0.9106425642967224,0.06901109963655472 59 | 1,0.018714630976319313,0.9596737623214722,0.021611597388982773 60 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 61 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 62 | 1,0.01976146176457405,0.9574180841445923,0.022820478305220604 63 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 64 | 1,0.017668401822447777,0.961928129196167,0.020403416827321053 65 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 66 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 67 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 68 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 69 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 70 | 1,0.017668401822447777,0.961928129196167,0.020403416827321053 71 | 1,0.01413514744490385,0.969541609287262,0.016323229297995567 72 | 2,0.04147931933403015,0.3940299153327942,0.5644907355308533 73 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 74 | 1,0.013431635685265064,0.9212871789932251,0.06528116762638092 75 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 76 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 77 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 78 | 1,0.013810329139232635,0.9472620487213135,0.03892765939235687 79 | 1,0.041565362364053726,0.6988396048545837,0.25959497690200806 80 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 81 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 82 | 1,0.01413514744490385,0.969541609287262,0.016323229297995567 83 | 1,0.01413514744490385,0.969541609287262,0.016323229297995567 84 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 85 | 1,0.05360295623540878,0.47451525926589966,0.47188183665275574 86 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 87 | 1,0.02034630998969078,0.9106425642967224,0.06901109963655472 88 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 89 | 1,0.014934414997696877,0.967819333076477,0.017246220260858536 90 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 91 | 1,0.01413514744490385,0.969541609287262,0.016323229297995567 92 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 93 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 94 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 95 | 1,0.01976146176457405,0.9574180841445923,0.022820478305220604 96 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 97 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 98 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 99 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 100 | 1,0.01413514744490385,0.969541609287262,0.016323229297995567 101 | 1,0.01416331809014082,0.9714738726615906,0.01436274591833353 102 | 2,0.014818643219769001,0.019509898498654366,0.9656714200973511 103 | 2,0.020867543295025826,0.024275926873087883,0.9548565745353699 104 | 2,0.014829451218247414,0.01879485882818699,0.9663757085800171 105 | 2,0.01486769039183855,0.01626470498740673,0.9688675999641418 106 | 2,0.01486769039183855,0.01626470498740673,0.9688675999641418 107 | 2,0.014829451218247414,0.01879485882818699,0.9663757085800171 108 | 2,0.05593302845954895,0.27763915061950684,0.6664277911186218 109 | 2,0.014829451218247414,0.01879485882818699,0.9663757085800171 110 | 2,0.014829451218247414,0.01879485882818699,0.9663757085800171 111 | 2,0.014818643219769001,0.019509898498654366,0.9656714200973511 112 | 2,0.016154633834958076,0.03942672163248062,0.9444186687469482 113 | 2,0.01486769039183855,0.01626470498740673,0.9688675999641418 114 | 2,0.014829451218247414,0.01879485882818699,0.9663757085800171 115 | 2,0.025735706090927124,0.030729640275239944,0.9435346722602844 116 | 2,0.020867543295025826,0.024275926873087883,0.9548565745353699 117 | 2,0.014818643219769001,0.019509898498654366,0.9656714200973511 118 | 2,0.01486769039183855,0.01626470498740673,0.9688675999641418 119 | 2,0.014818643219769001,0.019509898498654366,0.9656714200973511 120 | 2,0.014829451218247414,0.01879485882818699,0.9663757085800171 121 | 2,0.06410815566778183,0.2573493719100952,0.67854243516922 122 | 2,0.014818643219769001,0.019509898498654366,0.9656714200973511 123 | 2,0.025515154004096985,0.03046630136668682,0.944018542766571 124 | 2,0.014829451218247414,0.01879485882818699,0.9663757085800171 125 | 2,0.01634232886135578,0.019513515755534172,0.964144229888916 126 | 2,0.014818643219769001,0.019509898498654366,0.9656714200973511 127 | 2,0.014818643219769001,0.019509898498654366,0.9656714200973511 128 | 2,0.039063505828380585,0.11323655396699905,0.8476999402046204 129 | 2,0.015810759738087654,0.05140586569905281,0.9327834248542786 130 | 2,0.01486769039183855,0.01626470498740673,0.9688675999641418 131 | 2,0.051606908440589905,0.26434382796287537,0.6840493083000183 132 | 2,0.014829451218247414,0.01879485882818699,0.9663757085800171 133 | 2,0.014818643219769001,0.019509898498654366,0.9656714200973511 134 | 2,0.01486769039183855,0.01626470498740673,0.9688675999641418 135 | 2,0.04447225481271744,0.17029161751270294,0.7852361798286438 136 | 2,0.03355563431978226,0.07434805482625961,0.8920962810516357 137 | 2,0.014829451218247414,0.01879485882818699,0.9663757085800171 138 | 2,0.014818643219769001,0.019509898498654366,0.9656714200973511 139 | 2,0.01486769039183855,0.01626470498740673,0.9688675999641418 140 | 2,0.032686393707990646,0.2580006420612335,0.7093130350112915 141 | 2,0.014829451218247414,0.01879485882818699,0.9663757085800171 142 | 2,0.014829451218247414,0.01879485882818699,0.9663757085800171 143 | 2,0.01617845892906189,0.03801002725958824,0.9458115696907043 144 | 2,0.020867543295025826,0.024275926873087883,0.9548565745353699 145 | 2,0.014818643219769001,0.019509898498654366,0.9656714200973511 146 | 2,0.014818643219769001,0.019509898498654366,0.9656714200973511 147 | 2,0.014829451218247414,0.01879485882818699,0.9663757085800171 148 | 2,0.016486629843711853,0.019685810431838036,0.9638276100158691 149 | 2,0.01486769039183855,0.01626470498740673,0.9688675999641418 150 | 2,0.014818643219769001,0.019509898498654366,0.9656714200973511 151 | 2,0.020497728139162064,0.04156764969229698,0.9379346370697021 152 | --------------------------------------------------------------------------------