├── .github
└── workflows
│ └── maven.yml
├── LICENSE.txt
├── README.md
├── pmml-sparkml-evaluator
├── pom.xml
└── src
│ └── main
│ └── java
│ └── org
│ └── jpmml
│ └── sparkml
│ └── evaluator
│ └── SparkMLFunctionRegistry.java
├── pmml-sparkml-example
├── pom.xml
└── src
│ └── main
│ └── java
│ └── org
│ └── jpmml
│ └── sparkml
│ └── example
│ └── Main.java
├── pmml-sparkml-lightgbm
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── jpmml
│ │ │ └── sparkml
│ │ │ └── lightgbm
│ │ │ ├── BoosterUtil.java
│ │ │ ├── LightGBMClassificationModelConverter.java
│ │ │ └── LightGBMRegressionModelConverter.java
│ └── resources
│ │ └── META-INF
│ │ └── sparkml2pmml.properties
│ └── test
│ ├── java
│ └── org
│ │ └── jpmml
│ │ └── sparkml
│ │ └── lightgbm
│ │ └── testing
│ │ └── LightGBMTest.java
│ └── resources
│ ├── LightGBMAudit.scala
│ ├── LightGBMAuditNA.scala
│ ├── LightGBMAuto.scala
│ ├── LightGBMAutoNA.scala
│ ├── LightGBMIris.scala
│ ├── csv
│ ├── Audit.csv
│ ├── AuditNA.csv
│ ├── Auto.csv
│ ├── AutoNA.csv
│ ├── Iris.csv
│ ├── LightGBMAudit.csv
│ ├── LightGBMAuditNA.csv
│ ├── LightGBMAuto.csv
│ ├── LightGBMAutoNA.csv
│ └── LightGBMIris.csv
│ ├── pipeline
│ ├── LightGBMAudit.zip
│ ├── LightGBMAuditNA.zip
│ ├── LightGBMAuto.zip
│ ├── LightGBMAutoNA.zip
│ └── LightGBMIris.zip
│ └── schema
│ ├── Audit.json
│ ├── AuditNA.json
│ ├── Auto.json
│ ├── AutoNA.json
│ └── Iris.json
├── pmml-sparkml-xgboost
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── jpmml
│ │ │ └── sparkml
│ │ │ └── xgboost
│ │ │ ├── BoosterUtil.java
│ │ │ ├── XGBoostClassificationModelConverter.java
│ │ │ └── XGBoostRegressionModelConverter.java
│ └── resources
│ │ └── META-INF
│ │ └── sparkml2pmml.properties
│ └── test
│ ├── java
│ └── org
│ │ └── jpmml
│ │ └── sparkml
│ │ └── xgboost
│ │ └── testing
│ │ └── XGBoostTest.java
│ └── resources
│ ├── XGBoostAudit.scala
│ ├── XGBoostAuditNA.scala
│ ├── XGBoostAuto.scala
│ ├── XGBoostAutoNA.scala
│ ├── XGBoostHousing.scala
│ ├── XGBoostIris.scala
│ ├── csv
│ ├── Audit.csv
│ ├── AuditNA.csv
│ ├── Auto.csv
│ ├── AutoNA.csv
│ ├── Housing.csv
│ ├── Iris.csv
│ ├── XGBoostAudit.csv
│ ├── XGBoostAuditNA.csv
│ ├── XGBoostAuto.csv
│ ├── XGBoostAutoNA.csv
│ ├── XGBoostHousing.csv
│ └── XGBoostIris.csv
│ ├── pipeline
│ ├── XGBoostAudit.zip
│ ├── XGBoostAuditNA.zip
│ ├── XGBoostAuto.zip
│ ├── XGBoostAutoNA.zip
│ ├── XGBoostHousing.zip
│ └── XGBoostIris.zip
│ └── schema
│ ├── Audit.json
│ ├── AuditNA.json
│ ├── Auto.json
│ ├── AutoNA.json
│ ├── Housing.json
│ └── Iris.json
├── pmml-sparkml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── jpmml
│ │ │ └── sparkml
│ │ │ ├── AliasExpression.java
│ │ │ ├── ArchiveUtil.java
│ │ │ ├── AssociationRulesModelConverter.java
│ │ │ ├── BinarizedCategoricalFeature.java
│ │ │ ├── ClassificationModelConverter.java
│ │ │ ├── ClusteringModelConverter.java
│ │ │ ├── ConverterFactory.java
│ │ │ ├── DatasetUtil.java
│ │ │ ├── DocumentFeature.java
│ │ │ ├── ExpressionTranslator.java
│ │ │ ├── FeatureConverter.java
│ │ │ ├── HasSparkMLOptions.java
│ │ │ ├── ItemSetFeature.java
│ │ │ ├── MatrixUtil.java
│ │ │ ├── ModelConverter.java
│ │ │ ├── MultiFeatureConverter.java
│ │ │ ├── PMMLBuilder.java
│ │ │ ├── PipelineModelUtil.java
│ │ │ ├── PredictionModelConverter.java
│ │ │ ├── ProbabilisticClassificationModelConverter.java
│ │ │ ├── RegexKey.java
│ │ │ ├── RegressionModelConverter.java
│ │ │ ├── SparkMLEncoder.java
│ │ │ ├── SparkSessionUtil.java
│ │ │ ├── TermFeature.java
│ │ │ ├── TermUtil.java
│ │ │ ├── TransformerConverter.java
│ │ │ ├── VectorUtil.java
│ │ │ ├── WeightedTermFeature.java
│ │ │ ├── feature
│ │ │ ├── BinarizerConverter.java
│ │ │ ├── BucketizerConverter.java
│ │ │ ├── ChiSqSelectorModelConverter.java
│ │ │ ├── ColumnPrunerConverter.java
│ │ │ ├── CountVectorizerModelConverter.java
│ │ │ ├── IDFModelConverter.java
│ │ │ ├── ImputerModelConverter.java
│ │ │ ├── IndexToStringConverter.java
│ │ │ ├── InteractionConverter.java
│ │ │ ├── InvalidCategoryTransformerConverter.java
│ │ │ ├── MaxAbsScalerModelConverter.java
│ │ │ ├── MinMaxScalerModelConverter.java
│ │ │ ├── NGramConverter.java
│ │ │ ├── OneHotEncoderModelConverter.java
│ │ │ ├── PCAModelConverter.java
│ │ │ ├── RFormulaModelConverter.java
│ │ │ ├── RegexTokenizerConverter.java
│ │ │ ├── SQLTransformerConverter.java
│ │ │ ├── SparseToDenseTransformerConverter.java
│ │ │ ├── StandardScalerModelConverter.java
│ │ │ ├── StopWordsRemoverConverter.java
│ │ │ ├── StringIndexerModelConverter.java
│ │ │ ├── TokenizerConverter.java
│ │ │ ├── VectorAssemblerConverter.java
│ │ │ ├── VectorAttributeRewriterConverter.java
│ │ │ ├── VectorIndexerModelConverter.java
│ │ │ ├── VectorSizeHintConverter.java
│ │ │ └── VectorSlicerConverter.java
│ │ │ ├── model
│ │ │ ├── DecisionTreeClassificationModelConverter.java
│ │ │ ├── DecisionTreeRegressionModelConverter.java
│ │ │ ├── FPGrowthModelConverter.java
│ │ │ ├── GBTClassificationModelConverter.java
│ │ │ ├── GBTRegressionModelConverter.java
│ │ │ ├── GeneralizedLinearRegressionModelConverter.java
│ │ │ ├── HasFeatureImportances.java
│ │ │ ├── HasPredictionModelOptions.java
│ │ │ ├── HasRegressionTableOptions.java
│ │ │ ├── HasTreeOptions.java
│ │ │ ├── KMeansModelConverter.java
│ │ │ ├── LinearModelUtil.java
│ │ │ ├── LinearRegressionModelConverter.java
│ │ │ ├── LinearSVCModelConverter.java
│ │ │ ├── LogisticRegressionModelConverter.java
│ │ │ ├── MultilayerPerceptronClassificationModelConverter.java
│ │ │ ├── NaiveBayesModelConverter.java
│ │ │ ├── RandomForestClassificationModelConverter.java
│ │ │ ├── RandomForestRegressionModelConverter.java
│ │ │ ├── RegressionTableUtil.java
│ │ │ └── TreeModelUtil.java
│ │ │ ├── testing
│ │ │ ├── SparkMLEncoderBatch.java
│ │ │ └── SparkMLEncoderBatchTest.java
│ │ │ └── visitors
│ │ │ └── TreeModelCompactor.java
│ ├── resources
│ │ └── META-INF
│ │ │ └── sparkml2pmml.properties
│ └── scala
│ │ └── org
│ │ └── jpmml
│ │ └── sparkml
│ │ └── feature
│ │ ├── InvalidCategoryTransformer.scala
│ │ └── SparseToDenseTransformer.scala
│ └── test
│ ├── java
│ └── org
│ │ └── jpmml
│ │ └── sparkml
│ │ ├── AliasExpressionTest.java
│ │ ├── ExpressionTranslatorTest.java
│ │ ├── PMMLBuilderTest.java
│ │ ├── RegexKeyTest.java
│ │ ├── SparkMLTest.java
│ │ ├── TermUtilTest.java
│ │ ├── feature
│ │ ├── InvalidCategoryTransformerTest.java
│ │ ├── SQLTransformerConverterTest.java
│ │ └── SparseToDenseTransformerTest.java
│ │ └── testing
│ │ ├── AssociationRulesTest.java
│ │ ├── ClassificationTest.java
│ │ ├── ClusteringTest.java
│ │ ├── RegressionTest.java
│ │ ├── SimpleSparkMLEncoderBatchTest.java
│ │ └── SparkMLAlgorithms.java
│ └── resources
│ ├── common.py
│ ├── csv
│ ├── Audit.csv
│ ├── Auto.csv
│ ├── DecisionTreeAudit.csv
│ ├── DecisionTreeAuto.csv
│ ├── DecisionTreeHousing.csv
│ ├── DecisionTreeIris.csv
│ ├── DecisionTreeSentiment.csv
│ ├── GBTAudit.csv
│ ├── GBTAuto.csv
│ ├── GLMAudit.csv
│ ├── GLMAuto.csv
│ ├── GLMHousing.csv
│ ├── GLMSentiment.csv
│ ├── GLMVisit.csv
│ ├── Housing.csv
│ ├── Iris.csv
│ ├── KMeansIris.csv
│ ├── LinearRegressionAuto.csv
│ ├── LinearRegressionHousing.csv
│ ├── LinearSVCSentiment.csv
│ ├── LogisticRegressionAudit.csv
│ ├── LogisticRegressionIris.csv
│ ├── ModelChainAudit.csv
│ ├── ModelChainAuto.csv
│ ├── ModelChainIris.csv
│ ├── NaiveBayesAudit.csv
│ ├── NaiveBayesIris.csv
│ ├── NeuralNetworkAudit.csv
│ ├── NeuralNetworkIris.csv
│ ├── RandomForestAudit.csv
│ ├── RandomForestAuto.csv
│ ├── RandomForestHousing.csv
│ ├── RandomForestIris.csv
│ ├── RandomForestSentiment.csv
│ ├── Sentiment.csv
│ ├── Shopping.csv
│ └── Visit.csv
│ ├── main.py
│ ├── pipeline
│ ├── DecisionTreeAudit.zip
│ ├── DecisionTreeAuto.zip
│ ├── DecisionTreeHousing.zip
│ ├── DecisionTreeIris.zip
│ ├── DecisionTreeSentiment.zip
│ ├── FPGrowthShopping.zip
│ ├── GBTAudit.zip
│ ├── GBTAuto.zip
│ ├── GLMAudit.zip
│ ├── GLMAuto.zip
│ ├── GLMHousing.zip
│ ├── GLMSentiment.zip
│ ├── GLMVisit.zip
│ ├── KMeansIris.zip
│ ├── LinearRegressionAuto.zip
│ ├── LinearRegressionHousing.zip
│ ├── LinearSVCSentiment.zip
│ ├── LogisticRegressionAudit.zip
│ ├── LogisticRegressionIris.zip
│ ├── ModelChainAudit.zip
│ ├── ModelChainAuto.zip
│ ├── ModelChainIris.zip
│ ├── NaiveBayesAudit.zip
│ ├── NaiveBayesIris.zip
│ ├── NeuralNetworkAudit.zip
│ ├── NeuralNetworkIris.zip
│ ├── RandomForestAudit.zip
│ ├── RandomForestAuto.zip
│ ├── RandomForestHousing.zip
│ ├── RandomForestIris.zip
│ └── RandomForestSentiment.zip
│ └── schema
│ ├── Audit.json
│ ├── Auto.json
│ ├── Housing.json
│ ├── Iris.json
│ ├── Sentiment.json
│ ├── Shopping.json
│ └── Visit.json
└── pom.xml
/.github/workflows/maven.yml:
--------------------------------------------------------------------------------
1 | name: maven
2 |
3 | on:
4 | push:
5 | branches: [ '3.0.X', master ]
6 |
7 | jobs:
8 | build:
9 |
10 | runs-on: ubuntu-latest
11 | strategy:
12 | matrix:
13 | java: [ 11, 17 ]
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-sparkml-evaluator/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | org.jpmml
7 | jpmml-sparkml
8 | 3.1-SNAPSHOT
9 |
10 |
11 | org.jpmml
12 | pmml-sparkml-evaluator
13 | jar
14 |
15 | JPMML Spark ML JPMML-Evaluator integration
16 | JPMML Apache Spark ML JPMML-Evaluator integration
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-evaluator
30 | provided
31 |
32 |
33 | org.jpmml
34 | pmml-evaluator-testing
35 | provided
36 |
37 |
38 |
39 | org.junit.jupiter
40 | junit-jupiter-api
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/pmml-sparkml-evaluator/src/main/java/org/jpmml/sparkml/evaluator/SparkMLFunctionRegistry.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2025 Villu Ruusmann
3 | *
4 | * This file is part of JPMML-SparkML
5 | *
6 | * JPMML-SparkML 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-SparkML 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-SparkML. If not, see .
18 | */
19 | package org.jpmml.sparkml.evaluator;
20 |
21 | import java.util.Collections;
22 | import java.util.Map;
23 | import java.util.Objects;
24 | import java.util.function.Predicate;
25 |
26 | import org.jpmml.evaluator.Function;
27 | import org.jpmml.evaluator.FunctionRegistry;
28 |
29 | /**
30 | * @see FunctionRegistry
31 | */
32 | public class SparkMLFunctionRegistry {
33 |
34 | private SparkMLFunctionRegistry(){
35 | }
36 |
37 | static
38 | public void publish(String name){
39 | publish(key -> Objects.equals(name, key));
40 | }
41 |
42 | static
43 | public void publishAll(){
44 | publish(key -> true);
45 | }
46 |
47 | static
48 | private void publish(Predicate predicate){
49 | (SparkMLFunctionRegistry.functions.entrySet()).stream()
50 | .filter(entry -> predicate.test(entry.getKey()))
51 | .forEach(entry -> FunctionRegistry.putFunction(entry.getKey(), entry.getValue()));
52 |
53 | (SparkMLFunctionRegistry.functionClazzes.entrySet()).stream()
54 | .filter(entry -> predicate.test(entry.getKey()))
55 | .forEach(entry -> FunctionRegistry.putFunction(entry.getKey(), entry.getValue()));
56 | }
57 |
58 | private static final Map functions = Collections.emptyMap();
59 | private static final Map> functionClazzes = Collections.emptyMap();
60 | }
--------------------------------------------------------------------------------
/pmml-sparkml-lightgbm/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 |
6 | org.jpmml
7 | jpmml-sparkml
8 | 3.1-SNAPSHOT
9 |
10 |
11 | org.jpmml
12 | pmml-sparkml-lightgbm
13 | jar
14 |
15 | JPMML Spark ML LightGBM converter
16 | JPMML Apache Spark ML LightGBM 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-sparkml
30 |
31 |
32 |
33 | org.jpmml
34 | pmml-evaluator-testing
35 | provided
36 |
37 |
38 |
39 | org.jpmml
40 | pmml-lightgbm
41 |
42 |
43 |
44 | com.microsoft.azure
45 | synapseml-lightgbm_2.12
46 | provided
47 |
48 |
49 |
50 | org.apache.spark
51 | spark-core_2.12
52 | provided
53 |
54 |
55 | org.apache.spark
56 | spark-mllib_2.12
57 | provided
58 |
59 |
60 |
61 | org.junit.jupiter
62 | junit-jupiter-api
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/pmml-sparkml-lightgbm/src/main/java/org/jpmml/sparkml/lightgbm/BoosterUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Villu Ruusmann
3 | *
4 | * This file is part of JPMML-SparkML
5 | *
6 | * JPMML-SparkML 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-SparkML 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-SparkML. If not, see .
18 | */
19 | package org.jpmml.sparkml.lightgbm;
20 |
21 | import java.io.IOException;
22 | import java.io.StringReader;
23 | import java.util.LinkedHashMap;
24 | import java.util.List;
25 | import java.util.Map;
26 |
27 | import com.google.common.io.CharStreams;
28 | import com.microsoft.azure.synapse.ml.lightgbm.LightGBMModelMethods;
29 | import com.microsoft.azure.synapse.ml.lightgbm.booster.LightGBMBooster;
30 | import org.apache.spark.ml.Model;
31 | import org.apache.spark.ml.param.shared.HasPredictionCol;
32 | import org.dmg.pmml.mining.MiningModel;
33 | import org.jpmml.converter.Schema;
34 | import org.jpmml.lightgbm.GBDT;
35 | import org.jpmml.lightgbm.HasLightGBMOptions;
36 | import org.jpmml.lightgbm.LightGBMUtil;
37 | import org.jpmml.sparkml.ModelConverter;
38 | import scala.Option;
39 |
40 | public class BoosterUtil {
41 |
42 | private BoosterUtil(){
43 | }
44 |
45 | static
46 | public , M extends Model & HasPredictionCol & LightGBMModelMethods> MiningModel encodeModel(C converter, Schema schema){
47 | M model = converter.getModel();
48 |
49 | GBDT gbdt = BoosterUtil.getGBDT(model);
50 |
51 | Integer bestIteration = model.getBoosterBestIteration();
52 | if(bestIteration < 0){
53 | bestIteration = null;
54 | }
55 |
56 | Map options = new LinkedHashMap<>();
57 | options.put(HasLightGBMOptions.OPTION_COMPACT, converter.getOption(HasLightGBMOptions.OPTION_COMPACT, Boolean.TRUE));
58 | options.put(HasLightGBMOptions.OPTION_NUM_ITERATION, converter.getOption(HasLightGBMOptions.OPTION_NUM_ITERATION, bestIteration));
59 |
60 | Schema lgbmSchema = gbdt.toLightGBMSchema(schema);
61 |
62 | MiningModel miningModel = gbdt.encodeModel(options, lgbmSchema);
63 |
64 | return miningModel;
65 | }
66 |
67 | static
68 | private & LightGBMModelMethods> GBDT getGBDT(M model){
69 | LightGBMBooster booster = model.getLightGBMBooster();
70 |
71 | Option modelStr = booster.modelStr();
72 | if(modelStr.isEmpty()){
73 | throw new IllegalArgumentException();
74 | }
75 |
76 | String string = modelStr.get();
77 |
78 | try(StringReader reader = new StringReader(string)){
79 | List lines = CharStreams.readLines(reader);
80 |
81 | return LightGBMUtil.loadGBDT(lines.iterator());
82 | } catch(IOException ioe){
83 | throw new RuntimeException(ioe);
84 | }
85 | }
86 | }
--------------------------------------------------------------------------------
/pmml-sparkml-lightgbm/src/main/java/org/jpmml/sparkml/lightgbm/LightGBMClassificationModelConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Villu Ruusmann
3 | *
4 | * This file is part of JPMML-SparkML
5 | *
6 | * JPMML-SparkML 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-SparkML 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-SparkML. If not, see .
18 | */
19 | package org.jpmml.sparkml.lightgbm;
20 |
21 | import com.microsoft.azure.synapse.ml.lightgbm.LightGBMClassificationModel;
22 | import org.dmg.pmml.mining.MiningModel;
23 | import org.dmg.pmml.regression.RegressionModel;
24 | import org.jpmml.converter.Schema;
25 | import org.jpmml.converter.mining.MiningModelUtil;
26 | import org.jpmml.sparkml.ProbabilisticClassificationModelConverter;
27 |
28 | public class LightGBMClassificationModelConverter extends ProbabilisticClassificationModelConverter {
29 |
30 | public LightGBMClassificationModelConverter(LightGBMClassificationModel model){
31 | super(model);
32 | }
33 |
34 | @Override
35 | public int getNumberOfClasses(){
36 | int numberOfClasses = super.getNumberOfClasses();
37 |
38 | if(numberOfClasses == 1){
39 | return 2;
40 | }
41 |
42 | return numberOfClasses;
43 | }
44 |
45 | @Override
46 | public MiningModel encodeModel(Schema schema){
47 | LightGBMClassificationModel model = getModel();
48 |
49 | MiningModel miningModel = BoosterUtil.encodeModel(this, schema);
50 |
51 | RegressionModel regressionModel = (RegressionModel)MiningModelUtil.getFinalModel(miningModel);
52 | regressionModel.setOutput(null);
53 |
54 | return miningModel;
55 | }
56 | }
--------------------------------------------------------------------------------
/pmml-sparkml-lightgbm/src/main/java/org/jpmml/sparkml/lightgbm/LightGBMRegressionModelConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Villu Ruusmann
3 | *
4 | * This file is part of JPMML-SparkML
5 | *
6 | * JPMML-SparkML 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-SparkML 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-SparkML. If not, see .
18 | */
19 | package org.jpmml.sparkml.lightgbm;
20 |
21 | import com.microsoft.azure.synapse.ml.lightgbm.LightGBMRegressionModel;
22 | import org.dmg.pmml.mining.MiningModel;
23 | import org.jpmml.converter.Schema;
24 | import org.jpmml.sparkml.RegressionModelConverter;
25 |
26 | public class LightGBMRegressionModelConverter extends RegressionModelConverter {
27 |
28 | public LightGBMRegressionModelConverter(LightGBMRegressionModel model){
29 | super(model);
30 | }
31 |
32 | @Override
33 | public MiningModel encodeModel(Schema schema){
34 | LightGBMRegressionModel model = getModel();
35 |
36 | return BoosterUtil.encodeModel(this, schema);
37 | }
38 | }
--------------------------------------------------------------------------------
/pmml-sparkml-lightgbm/src/main/resources/META-INF/sparkml2pmml.properties:
--------------------------------------------------------------------------------
1 | com.microsoft.azure.synapse.ml.lightgbm.LightGBMClassificationModel = org.jpmml.sparkml.lightgbm.LightGBMClassificationModelConverter
2 | com.microsoft.azure.synapse.ml.lightgbm.LightGBMRegressionModel = org.jpmml.sparkml.lightgbm.LightGBMRegressionModelConverter
3 |
--------------------------------------------------------------------------------
/pmml-sparkml-lightgbm/src/test/java/org/jpmml/sparkml/lightgbm/testing/LightGBMTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Villu Ruusmann
3 | *
4 | * This file is part of JPMML-SparkML
5 | *
6 | * JPMML-SparkML 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-SparkML 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-SparkML. If not, see .
18 | */
19 | package org.jpmml.sparkml.lightgbm.testing;
20 |
21 | import java.util.LinkedHashMap;
22 | import java.util.List;
23 | import java.util.Map;
24 | import java.util.function.Predicate;
25 |
26 | import com.google.common.base.Equivalence;
27 | import org.jpmml.converter.testing.Datasets;
28 | import org.jpmml.converter.testing.OptionsUtil;
29 | import org.jpmml.evaluator.ResultField;
30 | import org.jpmml.evaluator.testing.PMMLEquivalence;
31 | import org.jpmml.lightgbm.HasLightGBMOptions;
32 | import org.jpmml.sparkml.testing.SparkMLEncoderBatch;
33 | import org.jpmml.sparkml.testing.SparkMLEncoderBatchTest;
34 | import org.junit.jupiter.api.AfterAll;
35 | import org.junit.jupiter.api.BeforeAll;
36 | import org.junit.jupiter.api.Test;
37 |
38 | public class LightGBMTest extends SparkMLEncoderBatchTest implements Datasets {
39 |
40 | public LightGBMTest(){
41 | super(new PMMLEquivalence(1e-14, 1e-14));
42 | }
43 |
44 | @Override
45 | public SparkMLEncoderBatch createBatch(String algorithm, String dataset, Predicate columnFilter, Equivalence