-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
574 additions
and
231 deletions.
There are no files selected for viewing
108 changes: 0 additions & 108 deletions
108
pmml-sklearn/src/test/java/org/jpmml/sklearn/testing/BSplineTest.java
This file was deleted.
Oops, something went wrong.
128 changes: 128 additions & 0 deletions
128
pmml-sklearn/src/test/java/org/jpmml/sklearn/testing/TransformerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
/* | ||
* Copyright (c) 2020 Villu Ruusmann | ||
* | ||
* This file is part of JPMML-SkLearn | ||
* | ||
* JPMML-SkLearn is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* JPMML-SkLearn is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with JPMML-SkLearn. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.jpmml.sklearn.testing; | ||
|
||
import java.util.function.Predicate; | ||
|
||
import com.google.common.base.Equivalence; | ||
import org.jpmml.converter.FieldNameUtil; | ||
import org.jpmml.evaluator.EvaluatorBuilder; | ||
import org.jpmml.evaluator.ModelEvaluatorBuilder; | ||
import org.jpmml.evaluator.ResultField; | ||
import org.junit.Test; | ||
import sklearn.Estimator; | ||
|
||
public class TransformerTest extends SkLearnEncoderBatchTest { | ||
|
||
@Override | ||
public SkLearnEncoderBatch createBatch(String algorithm, String dataset, Predicate<ResultField> columnFilter, Equivalence<Object> equivalence){ | ||
SkLearnEncoderBatch result = new SkLearnEncoderBatch(algorithm, dataset, columnFilter, equivalence){ | ||
|
||
@Override | ||
public TransformerTest getArchiveBatchTest(){ | ||
return TransformerTest.this; | ||
} | ||
|
||
@Override | ||
public String getSeparator(){ | ||
return "\t"; | ||
} | ||
|
||
@Override | ||
public EvaluatorBuilder getEvaluatorBuilder() throws Exception { | ||
ModelEvaluatorBuilder evaluatorBuilder = (ModelEvaluatorBuilder)super.getEvaluatorBuilder(); | ||
|
||
evaluatorBuilder | ||
.setDerivedFieldGuard(null) | ||
.setFunctionGuard(null); | ||
|
||
return evaluatorBuilder; | ||
} | ||
}; | ||
|
||
return result; | ||
} | ||
|
||
@Test | ||
public void evaluateCubic2Spline() throws Exception { | ||
evaluate("Cubic2", "Spline", excludeFields(TransformerTest.predictedValue)); | ||
} | ||
|
||
@Test | ||
public void evaluateCubic3Spline() throws Exception { | ||
evaluate("Cubic3", "Spline", excludeFields(TransformerTest.predictedValue)); | ||
} | ||
|
||
@Test | ||
public void evaluateQuadratic2Spline() throws Exception { | ||
evaluate("Quadratic2", "Spline", excludeFields(TransformerTest.predictedValue)); | ||
} | ||
|
||
@Test | ||
public void evaluateQuadratic3Spline() throws Exception { | ||
evaluate("Quadratic3", "Spline", excludeFields(TransformerTest.predictedValue)); | ||
} | ||
|
||
@Test | ||
public void evaluateQuadratic4Spline() throws Exception { | ||
evaluate("Quadratic4", "Spline", excludeFields(TransformerTest.predictedValue)); | ||
} | ||
|
||
@Test | ||
public void evaluateQuadratic5Spline() throws Exception { | ||
evaluate("Quadratic5", "Spline", excludeFields(TransformerTest.predictedValue)); | ||
} | ||
|
||
@Test | ||
public void evaluateSimpleBoxCox() throws Exception { | ||
evaluate("Plain", "BoxCox", excludeFields(TransformerTest.predictedValue)); | ||
} | ||
|
||
@Test | ||
public void evaluateStandardizedBoxCox() throws Exception { | ||
evaluate("Standardized", "BoxCox", excludeFields(TransformerTest.predictedValue, FieldNameUtil.create("power", TransformerTest.predictedValue))); | ||
} | ||
|
||
@Test | ||
public void evaluateSimpleYeoJohnson() throws Exception { | ||
evaluate("Plain", "YeoJohnson", excludeFields(TransformerTest.predictedValue)); | ||
} | ||
|
||
@Test | ||
public void evaluateStandardizedYeoJohnson() throws Exception { | ||
evaluate("Standardized", "YeoJohnson", excludeFields(TransformerTest.predictedValue, FieldNameUtil.create("power", TransformerTest.predictedValue))); | ||
} | ||
|
||
@Test | ||
public void evaluateGaussianBSpline() throws Exception { | ||
evaluate("Gaussian", "BSpline", excludeFields(TransformerTest.predictedValue)); | ||
} | ||
|
||
@Test | ||
public void evaluateSinBSpline() throws Exception { | ||
evaluate("Sin", "BSpline", excludeFields(TransformerTest.predictedValue)); | ||
} | ||
|
||
@Test | ||
public void evaluateTanhBSpline() throws Exception { | ||
evaluate("Tanh", "BSpline", excludeFields(TransformerTest.predictedValue)); | ||
} | ||
|
||
private static final String predictedValue = FieldNameUtil.create(Estimator.FIELD_PREDICT, "y"); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
x1 | ||
0.1 | ||
0.13076923076923078 | ||
0.16153846153846155 | ||
0.19230769230769232 | ||
0.2230769230769231 | ||
0.25384615384615383 | ||
0.2846153846153846 | ||
0.3153846153846154 | ||
0.34615384615384615 | ||
0.3769230769230769 | ||
0.4076923076923077 | ||
0.43846153846153846 | ||
0.46923076923076923 | ||
0.5 | ||
0.5307692307692308 | ||
0.5615384615384615 | ||
0.5923076923076923 | ||
0.6230769230769231 | ||
0.6538461538461539 | ||
0.6846153846153846 | ||
0.7153846153846154 | ||
0.7461538461538462 | ||
0.7769230769230769 | ||
0.8076923076923077 | ||
0.8384615384615385 | ||
0.8692307692307693 | ||
0.9 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
y bspline(predict(y), 0) bspline(predict(y), 1) bspline(predict(y), 2) bspline(predict(y), 3) | ||
0.0 0.16666666666666666 0.6666666666666666 0.16666666666666666 0.0 | ||
0.0384615384615384 0.14816605977848582 0.6652158246093157 0.18660863298437258 9.48262782582305e-06 | ||
0.0769230769230769 0.13108784706417845 0.6609770899711729 0.20785920194204213 7.586102260658467e-05 | ||
0.1153846153846153 0.1153751327567896 0.6541211500531028 0.23024768623881042 0.0002560309512972229 | ||
0.1538461538461538 0.10097102108936433 0.6448186921559703 0.25360339857381275 0.0006068881808526773 | ||
0.1923076923076923 0.08781861629494767 0.6332404035806403 0.27775565164618415 0.0011853284782278864 | ||
0.2307692307692307 0.07586102260658474 0.6195569716279775 0.30253375815505984 0.002048247610377786 | ||
0.2692307692307693 0.06504134425732057 0.6039390835988468 0.3277670307995752 0.003252541344257322 | ||
0.3076923076923077 0.055302685480200266 0.5865574267941132 0.3532847822788651 0.004855105446821424 | ||
0.3461538461538461 0.04658815050826887 0.5675826885146413 0.378916325292065 0.006912835685025031 | ||
0.3846153846153846 0.03884084357457139 0.5471855560612957 0.4044909725383098 0.009482627825823091 | ||
0.4230769230769231 0.03200386891215293 0.5255367167349415 0.42983803671673493 0.012621377636170536 | ||
0.4615384615384615 0.026020330754058577 0.5028068578364437 0.4547868305264755 0.0163859808830223 | ||
0.5 0.020833333333333332 0.47916666666666663 0.47916666666666663 0.020833333333333332 | ||
0.5384615384615385 0.016385980883022296 0.45478683052647545 0.5028068578364437 0.026020330754058577 | ||
0.576923076923077 0.012621377636170529 0.4298380367167349 0.5255367167349416 0.03200386891215295 | ||
0.6153846153846154 0.009482627825823091 0.4044909725383098 0.5471855560612957 0.03884084357457139 | ||
0.6538461538461539 0.006912835685025033 0.37891632529206504 0.5675826885146412 0.04658815050826885 | ||
0.6923076923076923 0.004855105446821424 0.3532847822788651 0.5865574267941132 0.055302685480200266 | ||
0.7307692307692308 0.0032525413442573183 0.32776703079957514 0.603939083598847 0.06504134425732061 | ||
0.7692307692307693 0.002048247610377787 0.30253375815505995 0.6195569716279776 0.07586102260658474 | ||
0.8076923076923077 0.0011853284782278864 0.27775565164618415 0.6332404035806403 0.08781861629494767 | ||
0.8461538461538463 0.0006068881808526767 0.2536033985738127 0.6448186921559702 0.10097102108936433 | ||
0.8846153846153847 0.000256030951297223 0.2302476862388105 0.6541211500531028 0.1153751327567896 | ||
0.9230769230769232 7.586102260658425e-05 0.20785920194204205 0.6609770899711729 0.1310878470641785 | ||
0.9615384615384616 9.482627825823073e-06 0.18660863298437258 0.6652158246093157 0.14816605977848582 | ||
1.0 0.0 0.16666666666666666 0.6666666666666666 0.16666666666666666 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
y bspline(predict(y), 0) bspline(predict(y), 1) bspline(predict(y), 2) bspline(predict(y), 3) bspline(predict(y), 4) | ||
0.0 0.16666666666666666 0.6666666666666666 0.16666666666666666 0.0 0.0 | ||
0.0384615384615384 0.1310878470641785 0.6609770899711729 0.2078592019420421 7.58610226065844e-05 0.0 | ||
0.0769230769230769 0.10097102108936433 0.6448186921559703 0.25360339857381275 0.0006068881808526773 0.0 | ||
0.1153846153846153 0.07586102260658478 0.6195569716279776 0.3025337581550598 0.002048247610377783 0.0 | ||
0.1538461538461538 0.05530268548020029 0.5865574267941133 0.35328478227886506 0.004855105446821419 0.0 | ||
0.1923076923076923 0.03884084357457139 0.5471855560612957 0.4044909725383098 0.009482627825823091 0.0 | ||
0.2307692307692307 0.026020330754058577 0.5028068578364436 0.4547868305264754 0.01638598088302229 0.0 | ||
0.2692307692307693 0.016385980883022296 0.45478683052647545 0.5028068578364437 0.026020330754058577 0.0 | ||
0.3076923076923077 0.009482627825823091 0.4044909725383098 0.5471855560612957 0.03884084357457139 0.0 | ||
0.3461538461538461 0.00485510544682143 0.35328478227886523 0.586557426794113 0.055302685480200245 0.0 | ||
0.3846153846153846 0.0020482476103777895 0.30253375815505995 0.6195569716279775 0.07586102260658473 0.0 | ||
0.4230769230769231 0.000606888180852678 0.25360339857381275 0.6448186921559702 0.10097102108936429 0.0 | ||
0.4615384615384615 7.586102260658492e-05 0.20785920194204227 0.6609770899711729 0.1310878470641784 0.0 | ||
0.5 0.0 0.16666666666666666 0.6666666666666666 0.16666666666666666 0.0 | ||
0.5384615384615385 0.0 0.13108784706417836 0.6609770899711728 0.20785920194204227 7.586102260658525e-05 | ||
0.576923076923077 0.0 0.10097102108936423 0.6448186921559702 0.25360339857381287 0.0006068881808526794 | ||
0.6153846153846154 0.0 0.07586102260658473 0.6195569716279775 0.30253375815505995 0.0020482476103777895 | ||
0.6538461538461539 0.0 0.055302685480200266 0.5865574267941132 0.3532847822788651 0.004855105446821424 | ||
0.6923076923076923 0.0 0.03884084357457139 0.5471855560612957 0.4044909725383098 0.009482627825823091 | ||
0.7307692307692308 0.0 0.026020330754058546 0.5028068578364435 0.4547868305264756 0.016385980883022316 | ||
0.7692307692307693 0.0 0.016385980883022296 0.45478683052647545 0.5028068578364437 0.026020330754058577 | ||
0.8076923076923077 0.0 0.009482627825823091 0.4044909725383098 0.5471855560612957 0.03884084357457139 | ||
0.8461538461538463 0.0 0.004855105446821413 0.35328478227886495 0.5865574267941133 0.05530268548020032 | ||
0.8846153846153847 0.0 0.002048247610377784 0.3025337581550598 0.6195569716279776 0.07586102260658478 | ||
0.9230769230769232 0.0 0.000606888180852674 0.2536033985738126 0.6448186921559704 0.1009710210893644 | ||
0.9615384615384616 0.0 7.586102260658458e-05 0.20785920194204213 0.6609770899711728 0.13108784706417845 | ||
1.0 0.0 0.0 0.16666666666666666 0.6666666666666666 0.16666666666666666 |
Oops, something went wrong.