diff --git a/README.md b/README.md index 1d1ddf9..962eafa 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Java library and command-line application for converting [H2O.ai](https://www.h2 * Unsupervised algorithms: * Isolation Forest: * [`IsolationForestMojoModel`](https://docs.h2o.ai/h2o/latest-stable/h2o-genmodel/javadoc/hex/genmodel/algos/isofor/IsolationForestMojoModel.html) + * [`ExtendedIsolationForestMojoModel`](https://docs.h2o.ai/h2o/latest-stable/h2o-genmodel/javadoc/hex/genmodel/algos/isoforextended/ExtendedIsolationForestMojoModel.html) # Prerequisites # diff --git a/pmml-h2o/src/main/java/org/jpmml/h2o/ConverterFactory.java b/pmml-h2o/src/main/java/org/jpmml/h2o/ConverterFactory.java index 4d27fb5..e30c84b 100644 --- a/pmml-h2o/src/main/java/org/jpmml/h2o/ConverterFactory.java +++ b/pmml-h2o/src/main/java/org/jpmml/h2o/ConverterFactory.java @@ -26,6 +26,7 @@ import hex.genmodel.algos.glm.GlmMultinomialMojoModel; import hex.genmodel.algos.glm.GlmOrdinalMojoModel; import hex.genmodel.algos.isofor.IsolationForestMojoModel; +import hex.genmodel.algos.isoforextended.ExtendedIsolationForestMojoModel; public class ConverterFactory { @@ -38,6 +39,10 @@ public Converter newConverter(MojoModel model){ return new DrfMojoModelConverter((DrfMojoModel)model); } else + if(model instanceof ExtendedIsolationForestMojoModel){ + return new ExtendedIsolationForestMojoModelConverter((ExtendedIsolationForestMojoModel)model); + } else + if(model instanceof GbmMojoModel){ return new GbmMojoModelConverter((GbmMojoModel)model); } else diff --git a/pmml-h2o/src/main/java/org/jpmml/h2o/ExtendedIsolationForestMojoModelConverter.java b/pmml-h2o/src/main/java/org/jpmml/h2o/ExtendedIsolationForestMojoModelConverter.java new file mode 100644 index 0000000..0cdb2f3 --- /dev/null +++ b/pmml-h2o/src/main/java/org/jpmml/h2o/ExtendedIsolationForestMojoModelConverter.java @@ -0,0 +1,294 @@ +/* + * Copyright (c) 2024 Villu Ruusmann + * + * This file is part of JPMML-H2O + * + * JPMML-H2O 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-H2O 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-H2O. If not, see . + */ +package org.jpmml.h2o; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.google.common.collect.Iterables; +import hex.genmodel.algos.isoforextended.ExtendedIsolationForestMojoModel; +import hex.genmodel.utils.ByteBufferWrapper; +import org.dmg.pmml.Apply; +import org.dmg.pmml.DataType; +import org.dmg.pmml.DerivedField; +import org.dmg.pmml.Expression; +import org.dmg.pmml.FieldRef; +import org.dmg.pmml.MiningFunction; +import org.dmg.pmml.OpType; +import org.dmg.pmml.PMMLFunctions; +import org.dmg.pmml.Predicate; +import org.dmg.pmml.SimplePredicate; +import org.dmg.pmml.True; +import org.dmg.pmml.mining.MiningModel; +import org.dmg.pmml.mining.Segmentation; +import org.dmg.pmml.tree.BranchNode; +import org.dmg.pmml.tree.CountingLeafNode; +import org.dmg.pmml.tree.LeafNode; +import org.dmg.pmml.tree.Node; +import org.dmg.pmml.tree.TreeModel; +import org.jpmml.converter.ContinuousFeature; +import org.jpmml.converter.ContinuousLabel; +import org.jpmml.converter.ExpressionUtil; +import org.jpmml.converter.Feature; +import org.jpmml.converter.FieldNameUtil; +import org.jpmml.converter.Label; +import org.jpmml.converter.ModelEncoder; +import org.jpmml.converter.ModelUtil; +import org.jpmml.converter.Schema; +import org.jpmml.converter.Transformation; +import org.jpmml.converter.ValueUtil; +import org.jpmml.converter.mining.MiningModelUtil; +import org.jpmml.converter.transformations.AbstractTransformation; + +public class ExtendedIsolationForestMojoModelConverter extends Converter { + + public ExtendedIsolationForestMojoModelConverter(ExtendedIsolationForestMojoModel model){ + super(model); + } + + @Override + public MiningModel encodeModel(Schema schema){ + ExtendedIsolationForestMojoModel model = getModel(); + + long sampleSize = getSampleSize(model); + + List treeModels = encodeTreeModels(schema); + + Transformation anomalyScore = new AbstractTransformation(){ + + @Override + public String getName(String name){ + return "anomalyScore"; + } + + @Override + public boolean isFinalResult(){ + return true; + } + + @Override + public Expression createExpression(FieldRef fieldRef){ + return ExpressionUtil.createApply(PMMLFunctions.POW, ExpressionUtil.createConstant(2d), ExpressionUtil.createApply(PMMLFunctions.DIVIDE, fieldRef, ExpressionUtil.createConstant(-1d * ExtendedIsolationForestMojoModel.averagePathLengthOfUnsuccessfulSearch(sampleSize)))); + } + }; + + MiningModel miningModel = new MiningModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(null)) + .setSegmentation(MiningModelUtil.createSegmentation(Segmentation.MultipleModelMethod.AVERAGE, Segmentation.MissingPredictionTreatment.RETURN_MISSING, treeModels)) + .setOutput(ModelUtil.createPredictedOutput("meanPathLength", OpType.CONTINUOUS, DataType.DOUBLE, anomalyScore)); + + return miningModel; + } + + private List encodeTreeModels(Schema schema){ + ExtendedIsolationForestMojoModel model = getModel(); + + byte[][] compressedTrees = getCompressedTrees(model); + + List result = new ArrayList<>(); + + for(int i = 0, max = compressedTrees.length; i < max; i++){ + byte[] compressedTree = compressedTrees[i]; + + TreeModel treeModel = encodeTreeModel(i, compressedTree, schema); + + result.add(treeModel); + } + + return result; + } + + private TreeModel encodeTreeModel(int index, byte[] compressedTree, Schema schema){ + ByteBufferWrapper byteBuffer = new ByteBufferWrapper(compressedTree); + + Map nodeMap = new HashMap<>(); + Map featureMap = new HashMap<>(); + Map countMap = new HashMap<>(); + + int sizeOfBranchingArrays = byteBuffer.get4(); + + double[] n = new double[sizeOfBranchingArrays]; + double[] p = new double[sizeOfBranchingArrays]; + + while(byteBuffer.hasRemaining()){ + int nodeNumber = byteBuffer.get4(); + int nodeType = byteBuffer.get1U(); + + if(nodeNumber == 0){ + + if(!nodeMap.isEmpty()){ + break; + } + } + + Node node; + + switch(nodeType){ + case 'N': + node = new BranchNode(); + + Feature feature = loadFeature(FieldNameUtil.create("split", index, nodeNumber), byteBuffer, n, p, schema); + featureMap.put(nodeNumber, feature); + + break; + case 'L': + node = new CountingLeafNode(); + + int numRows = loadSampleSize(byteBuffer); + countMap.put(nodeNumber, numRows); + + break; + default: + throw new IllegalArgumentException(); + } + + nodeMap.put(nodeNumber, node); + } + + Label label = new ContinuousLabel(DataType.DOUBLE); + + Node root = encodeNode(0, True.INSTANCE, 0, nodeMap, featureMap, countMap); + + TreeModel treeModel = new TreeModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(label), root); + + return treeModel; + } + + static + private Node encodeNode(int index, Predicate predicate, int height, Map nodeMap, Map featureMap, Map countMap){ + Node result = nodeMap.get(index); + + result + .setId(index) + .setPredicate(predicate); + + if(result instanceof BranchNode){ + Feature feature = featureMap.get(index); + + String name = feature.getName(); + + Predicate leftPredicate = new SimplePredicate(name, SimplePredicate.Operator.LESS_OR_EQUAL, 0); + Predicate rightPredicate = new SimplePredicate(name, SimplePredicate.Operator.GREATER_THAN, 0); + + Node leftChild = encodeNode(2 * index + 1, leftPredicate, height + 1, nodeMap, featureMap, countMap); + Node rightChild = encodeNode(2 * index + 2, rightPredicate, height + 1, nodeMap, featureMap, countMap); + + result.addNodes(leftChild, rightChild); + } else + + if(result instanceof LeafNode){ + Integer numRows = countMap.get(index); + + result.setScore(height + ExtendedIsolationForestMojoModel.averagePathLengthOfUnsuccessfulSearch(numRows)); + } else + + { + throw new IllegalArgumentException(); + } + + return result; + } + + static + private Feature loadFeature(String name, ByteBufferWrapper byteBuffer, double[] n, double[] p, Schema schema){ + ModelEncoder encoder = (ModelEncoder)schema.getEncoder(); + + for(int i = 0; i < n.length; i++){ + n[i] = byteBuffer.get8d(); + } + + for(int i = 0; i < p.length; i++){ + p[i] = byteBuffer.get8d(); + } + + List expressions = new ArrayList<>(); + + for(int i = 0; i < n.length; i++){ + Feature feature = schema.getFeature(i); + + if(ValueUtil.isZero(n[i])){ + continue; + } + + ContinuousFeature continuousFeature = feature.toContinuousFeature(); + + Expression expression = continuousFeature.ref(); + + if(!ValueUtil.isOne(p[i])){ + expression = ExpressionUtil.createApply(PMMLFunctions.SUBTRACT, expression, ExpressionUtil.createConstant(p[i])); + } + + expression = ExpressionUtil.createApply(PMMLFunctions.MULTIPLY, expression, ExpressionUtil.createConstant(n[i])); + + expressions.add(expression); + } + + Expression expression; + + if(expressions.size() == 1){ + expression = Iterables.getOnlyElement(expressions); + } else + + if(expressions.size() >= 2){ + Apply apply = ExpressionUtil.createApply(PMMLFunctions.SUM); + + (apply.getExpressions()).addAll(expressions); + + expression =apply; + } else + + { + throw new IllegalArgumentException(); + } + + DerivedField derivedField = encoder.createDerivedField(name, OpType.CONTINUOUS, DataType.DOUBLE, expression); + + return new ContinuousFeature(encoder, derivedField); + } + + static + private int loadSampleSize(ByteBufferWrapper byteBuffer){ + return byteBuffer.get4(); + } + + static + public byte[][] getCompressedTrees(ExtendedIsolationForestMojoModel model){ + return (byte[][])getFieldValue(FIELD_COMPRESSEDTREES, model); + } + + static + public long getSampleSize(ExtendedIsolationForestMojoModel model){ + return (long)getFieldValue(FIELD_SAMPLE_SIZE, model); + } + + private static final Field FIELD_COMPRESSEDTREES; + private static final Field FIELD_SAMPLE_SIZE; + + static { + + try { + FIELD_COMPRESSEDTREES = ExtendedIsolationForestMojoModel.class.getDeclaredField("_compressedTrees"); + FIELD_SAMPLE_SIZE = ExtendedIsolationForestMojoModel.class.getDeclaredField("_sample_size"); + } catch(ReflectiveOperationException roe){ + throw new RuntimeException(roe); + } + } +} \ No newline at end of file diff --git a/pmml-h2o/src/test/java/org/jpmml/h2o/testing/ExtendedIsolationForestMojoModelConverterTest.java b/pmml-h2o/src/test/java/org/jpmml/h2o/testing/ExtendedIsolationForestMojoModelConverterTest.java new file mode 100644 index 0000000..89523ba --- /dev/null +++ b/pmml-h2o/src/test/java/org/jpmml/h2o/testing/ExtendedIsolationForestMojoModelConverterTest.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 Villu Ruusmann + * + * This file is part of JPMML-H2O + * + * JPMML-H2O 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-H2O 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-H2O. If not, see . + */ +package org.jpmml.h2o.testing; + +import org.jpmml.converter.testing.Datasets; +import org.junit.Test; + +public class ExtendedIsolationForestMojoModelConverterTest extends H2OEncoderBatchTest implements Datasets { + + @Test + public void evaluateHousing() throws Exception { + evaluate("ExtendedIsolationForest", HOUSING, excludeFields("meanPathLength")); + } +} \ No newline at end of file diff --git a/pmml-h2o/src/test/resources/csv/ExtendedIsolationForestHousing.csv b/pmml-h2o/src/test/resources/csv/ExtendedIsolationForestHousing.csv new file mode 100644 index 0000000..8fd7141 --- /dev/null +++ b/pmml-h2o/src/test/resources/csv/ExtendedIsolationForestHousing.csv @@ -0,0 +1,507 @@ +anomalyScore,meanPathLength +0.4263664165622347,12.599370555536112 +0.3983499729820057,13.603945431300527 +0.4112108867444045,13.134304815953175 +0.4265107945940415,12.594366508337034 +0.4280025958371937,12.542760612711376 +0.4210574741067235,12.78456151536441 +0.3649742344968028,14.897264338011428 +0.4098843326698659,13.182061987614492 +0.4363981073636253,12.255647852921316 +0.4148051848255522,13.005676933203992 +0.4163646911227149,12.950213770108242 +0.4080640269401732,13.247846847443018 +0.3800572234384565,14.298743974742342 +0.380968417677835,14.263350869319462 +0.3868935260012434,14.035249150985772 +0.3787747514128085,14.348702484848936 +0.3914268584140717,13.863073847117375 +0.3760939303440271,14.453682113594278 +0.5127603689315321,9.872305205669356 +0.3689119672528564,14.738655103132915 +0.4074099180496808,13.271557682092732 +0.3823345806414766,14.210443911593762 +0.3947755636734281,13.737166243109316 +0.3986351965735902,13.593366494828468 +0.3934397284344299,13.787263649411448 +0.4819906852817176,10.786953179539008 +0.3907131894983986,13.890046220585486 +0.4938149674133619,10.428741701287628 +0.3997088934678617,13.553610865707196 +0.3941226731346845,13.761630175916608 +0.4219326738848034,12.753871886094576 +0.4063087826077907,13.31155892592508 +0.5629387252251502,8.492404888415583 +0.4126286197331001,13.083435131269638 +0.5668813760468665,8.389250533441531 +0.3686270096131984,14.75007605066206 +0.3775492086585637,14.396601631267403 +0.375955750004271,14.459113447667583 +0.3761661123082437,14.45084571351184 +0.432850669621907,12.376284675895526 +0.4345768131203175,12.317461146483762 +0.4836518254155317,10.736102459215612 +0.4793913089389826,10.866877881002903 +0.4658714680586139,11.28969778877438 +0.4043283740827295,13.38377534192193 +0.3921186875422662,13.836973787687745 +0.4001759822485314,13.536349355622947 +0.4183702257672396,12.87919237318485 +0.4675389032202018,11.236891751059613 +0.3892612069661726,13.945074803997814 +0.4020434149996406,13.46753811575114 +0.4110072937537301,13.14162433494096 +0.433499584161807,12.354143490629234 +0.4168457967002352,12.933145382431144 +0.5621471199096482,8.513203287101915 +0.4819447657080558,10.78836135470542 +0.4268553212688349,12.58243228206062 +0.4663135460778598,11.275679221707716 +0.4035612038966699,13.4118456143835 +0.3843291374271648,14.133539852945637 +0.3844041269971288,14.13065627313154 +0.4293340692914337,12.49685262565825 +0.4089622648360844,13.215348423282038 +0.3890419727594411,13.953401377314004 +0.4424104218191084,12.053410679867316 +0.4259575761455027,12.613549892652198 +0.4102445569215315,13.169078312145688 +0.4185751592975147,12.87195430454136 +0.3940167993250345,13.765601106093204 +0.4010750656168165,13.503179901670364 +0.4449501484295229,11.96880591659735 +0.3887764967985163,13.963490508132995 +0.4638280235265474,11.354670014705189 +0.4385988264130553,12.181300454930945 +0.4811591412670082,10.812474214674738 +0.3957767666561024,13.699729459418412 +0.405119325278245,13.35489064477562 +0.4030933651410614,13.428989743655116 +0.3943153365326878,13.754406829258675 +0.4248989725475412,12.65032754730304 +0.4093866332687381,13.20001950905889 +0.4030927982887486,13.429010528240674 +0.3990474513508192,13.578089343622434 +0.3890262239999368,13.95399970000486 +0.4010319466109608,13.504768972344612 +0.4220021896229037,12.75143698683602 +0.4059687231807507,13.323934267757757 +0.3998948956278626,13.546734642934016 +0.4241351288363428,12.67692170727952 +0.3956079894811945,13.706033700686126 +0.3854350749931891,14.09107007607934 +0.3914129277006933,13.863599873169376 +0.4171788745319341,12.921340174510147 +0.4405934508126549,12.114237174370212 +0.4393175197553428,12.157101457706313 +0.4331245313056932,12.366936376357431 +0.3792967173836449,14.32834899458284 +0.4034892636252072,13.41448059949916 +0.4204046165236783,12.8074960943102 +0.397513589046544,13.635010620828094 +0.3902684121870385,13.906881047501374 +0.3977836582137982,13.624972502076515 +0.6354068848481405,6.702614458024619 +0.4011937800992035,13.498805782962068 +0.4017405077626151,13.478677909275254 +0.4192407608090729,12.8484702776647 +0.4159238406227961,12.965871336220264 +0.4137994963870958,13.041554507670869 +0.4049443183396852,13.361276850719689 +0.3998146452057854,13.549700989133289 +0.3884248163724252,13.976866361131682 +0.4513556634898925,11.757548470996252 +0.4460352447047664,11.932805735164417 +0.4495922980940044,11.81540467660885 +0.45426816002321,11.662482330641122 +0.4753022134590273,10.993489253788423 +0.4417609124021792,12.075125482483225 +0.4513556634898925,11.757548470996252 +0.475576613163545,10.984958935015795 +0.462479418790252,11.397706482588587 +0.5213268325240509,9.627420799020529 +0.5227566041845737,9.586940982410374 +0.5237261707894673,9.559553477094274 +0.52759999657677,9.45063254138038 +0.5216459251404537,9.61837700650604 +0.5202506149928404,9.657964062268409 +0.5703482177033694,8.299136177040154 +0.4317209019799535,12.41491205252906 +0.4334425401345891,12.356088523117297 +0.4290901247828779,12.505252946905284 +0.4386487580313888,12.179617934882003 +0.4386487580313888,12.179617934882003 +0.4508217975754088,11.775040776655525 +0.4351710439237629,12.297264993705532 +0.5393658427572776,9.124647972366688 +0.4348119998156716,12.3094645441518 +0.4314653853142153,12.423662323422672 +0.4334425401345891,12.356088523117297 +0.4335745028584232,12.351589373596074 +0.4339325251088117,12.339389823149803 +0.4335745028584232,12.351589373596074 +0.5106310455413505,9.933809758964593 +0.4505172213627911,11.785029606444796 +0.466357739378708,11.274278555596132 +0.4577333062196529,11.550168070102384 +0.6174392702180205,7.126578714353239 +0.6076876630237568,7.361872832000298 +0.4617723208374422,11.420321460832588 +0.4544224841576855,11.657462089437782 +0.4289496226841809,12.510093357415196 +0.4407655082494013,12.108466488724972 +0.447911686429934,11.870757309340163 +0.4549980083140114,11.638755024016696 +0.5502597858335105,8.829099275076128 +0.4707049797369041,11.137141476507985 +0.6113152815325332,7.273904790553165 +0.6294773776308697,6.8411871904040495 +0.4464097993920388,11.920399484091831 +0.4291610736113271,12.50280930481301 +0.4251302750848158,12.642283894344914 +0.4663823757958285,11.273497784585905 +0.4582368567518263,11.533917501466734 +0.4455470395587717,11.9489920413778 +0.4347848436930957,12.310387660818472 +0.4381632038680103,12.195987534117291 +0.5704153410593095,8.297396835740702 +0.4534157078392132,11.690243792087612 +0.5896957821948031,7.806077165545438 +0.4662170583763851,11.27873777220361 +0.4418077483073693,12.073558567615256 +0.4638116569146912,11.355191553058894 +0.4298626029347809,12.478668731619262 +0.3959904436489537,13.6917519551037 +0.3988204629773291,13.586499022455872 +0.3745648826665002,14.51389449815606 +0.3921066484155716,13.83742758393726 +0.3706675854515233,14.668484892440338 +0.3802292557819447,14.292055306860185 +0.3802292557819447,14.292055306860185 +0.4738288312575467,11.039376962801818 +0.491762226916004,10.490309102054146 +0.453045741698037,11.702308573319826 +0.5230631884632819,9.578275358773324 +0.513300281383273,9.856750666914596 +0.5133400252255583,9.85560631835745 +0.4667102309175493,11.263111408875597 +0.4859673596472712,10.66551011277533 +0.4337808860021219,12.3445556720411 +0.4382799219483269,12.192050935044447 +0.4409646155244214,12.101791381537018 +0.4569316502845446,11.576076009319934 +0.438488640468118,12.18501401184132 +0.4381620484277951,12.196026509369924 +0.4518927985410927,11.73996991890275 +0.4242328725616716,12.673515968016456 +0.4222052410607794,12.74432708354537 +0.4158819343015563,12.967360575194236 +0.511625424714421,9.90505570557043 +0.4307828857188196,12.447060226794584 +0.4983710352359116,10.29300198927676 +0.4963915004418396,10.351825518688525 +0.4439750016013162,12.00123329051081 +0.4211427446086245,12.781568628796066 +0.5090344730472968,9.98009452267162 +0.5070125829703539,10.038918052083384 +0.3858502039729813,14.075159905419788 +0.3810464773822501,14.26032276920416 +0.3759314840936366,14.4600674527077 +0.3791724708082357,14.333191312225598 +0.4367220276124056,12.244681280776836 +0.4048721186797644,13.36391230418345 +0.4286174730853702,12.521542485953397 +0.3702119110202969,14.686665731620254 +0.3942826710712641,13.755631276024408 +0.5599094124725394,8.572154932193174 +0.3820684634084181,14.220734907259263 +0.3858322163670454,14.075848940834891 +0.4037362081196278,13.405437625325357 +0.4262884543992568,12.60207337719104 +0.4223315530492827,12.739905958622382 +0.3903434844819227,13.904038214725052 +0.4198644724109342,12.826498041451869 +0.3687025890203193,14.747046008995998 +0.3841778824433762,14.139357785019996 +0.4016955605690117,13.480331614288431 +0.4192706216485313,12.84741758926595 +0.4377223780100523,12.210864915867695 +0.4267802641850946,12.585031399855458 +0.4105634379184422,13.157594294017658 +0.4049031655883131,13.36277896310106 +0.3655633222687571,14.87342773626046 +0.4130809920875301,13.067240332874071 +0.4000345204095134,13.541575023971395 +0.4037565902042801,13.404691491498468 +0.4063744555562834,13.309170168775134 +0.3728203991056647,14.58289145164758 +0.3709164096589636,14.658566550339376 +0.3921804662621523,13.834645353614796 +0.4122439924355839,13.097218647980254 +0.3899389990666213,13.919361709843905 +0.3846005203962778,14.12310700730223 +0.3834874249467727,14.165944944369572 +0.3925877806737968,13.819302887261404 +0.4380994973616817,12.198136632266124 +0.4367647567682319,12.243235259241416 +0.4192210176982366,12.849166325520718 +0.3936282221253944,13.780184332000005 +0.4320289959508585,12.404368135120558 +0.419464590788927,12.840581392429902 +0.4249312352864159,12.64920533285615 +0.4347657751111614,12.311035892593068 +0.4768090041063492,10.94670794337848 +0.4665072899681991,11.269539671285411 +0.4704229309874094,11.146000428018327 +0.4253980578982902,12.632977087182764 +0.4231601681181149,12.710935832037142 +0.436526400304311,12.251303422332834 +0.4553525881903652,11.627241395541049 +0.4556820702823331,11.616550755154828 +0.4460052488351192,11.933799728962857 +0.4260274773780975,12.611124625161931 +0.4356005377985116,12.282684925722474 +0.4537324956925679,11.679921002379068 +0.4268811247491057,12.581538850581207 +0.4427965948052378,12.04051501148345 +0.3912192084625722,13.870916684739402 +0.435908841666951,12.272227766684562 +0.4046613262740388,13.371609401202296 +0.4227438237265332,12.725485010325103 +0.4021114246710006,13.465038128559652 +0.4185474462281232,12.872932898084724 +0.444592818253717,11.980680259127634 +0.4086496859787125,13.226649483159466 +0.4132765801718057,13.06024382743121 +0.4234514772413122,12.700764527643194 +0.4387056775731772,12.17770017995947 +0.4216353772194917,12.764289702969252 +0.4186294165230973,12.870038581264389 +0.4086145458072906,13.227920490826335 +0.4235629683902003,12.696873571260246 +0.4363039184903834,12.258838218165732 +0.4286332815483268,12.52099737042186 +0.4491282348431992,11.830668359641978 +0.5139561275167591,9.837878144561191 +0.4377145467710355,12.211129346890589 +0.4047583890317373,13.368064650998882 +0.6208711935104763,7.0446538128614975 +0.4121552722654715,13.10039985226066 +0.4250658042252193,12.64452545838058 +0.4361735547832408,12.263255033774833 +0.4541619778195621,11.665937481296432 +0.4541619778195621,11.665937481296432 +0.4524967728080341,11.720228891993727 +0.4065956170054348,13.301128583612538 +0.3906449323444801,13.892628509509365 +0.4054228114318977,13.343822620801316 +0.3993972504995938,13.565139017088638 +0.3934594229632867,13.786523817082038 +0.4561331775650994,11.601926296135344 +0.4639817134376455,11.349773430540417 +0.4386471539319633,12.179671984417254 +0.3905849261798505,13.894899021620176 +0.3993808605190034,13.565745556562666 +0.4362246834187702,12.261522601723753 +0.4289414642153422,12.510374471942676 +0.4448406825789789,11.972442533209133 +0.4439993034317857,12.0004242963734 +0.4282198221737771,12.535261106326292 +0.3954521500149765,13.711857075481689 +0.3719191169415237,14.618665111796892 +0.3831185343477223,14.180169287382473 +0.3827690516334278,14.193657906337442 +0.406251358928687,13.313647944425115 +0.3765851089139491,14.43439192665251 +0.3962127875382155,13.6834554461461 +0.3706557125563507,14.668958322436028 +0.3772427845184063,14.40860221859995 +0.3738797282386297,14.540954991546172 +0.3689047655183826,14.738943636066336 +0.3670086019226459,14.8151088839882 +0.3747178132326634,14.507861191696666 +0.381171704046937,14.255466259062612 +0.3754627672003945,14.478506971403917 +0.3729850377783802,14.576365962005944 +0.391034426687788,13.877899303621978 +0.400821632121963,13.512522171104708 +0.385168633385578,14.101290708146422 +0.3762403920686626,14.447927448415724 +0.4936082577605321,10.434929899446203 +0.4896948113635593,10.552576958269736 +0.4810471793436413,10.815913822540326 +0.4015706411984168,13.484928641592544 +0.4338357349035847,12.342686940750967 +0.4229698979428865,12.717583057115249 +0.4229698979428865,12.717583057115249 +0.4079127047870826,13.253328752741586 +0.4087362913482723,13.223517463897403 +0.4118515784062299,13.111294469934942 +0.4017623809649612,13.477873213512355 +0.4090995114530223,13.21038910093364 +0.4008273990866441,13.512309518941006 +0.4139534374559785,13.036057066882446 +0.4438811909675382,12.004356608696243 +0.4575889056409885,11.554831459942276 +0.4329590573445805,12.372584141719376 +0.4055641872702463,13.33866952647587 +0.4185946064428886,12.871267632900482 +0.4504843915487836,11.786106690608229 +0.4194361723065785,12.841582768199135 +0.4035646134477834,13.41172074304913 +0.4232616988240225,12.707390006859333 +0.4634587767473764,11.36644090866622 +0.4799235075829634,10.850478802592653 +0.5522475286528877,8.775804335918709 +0.436678736827899,12.2461464529946 +0.4395646953883414,12.148787998375935 +0.43544280949467,12.28803767197454 +0.4322474412262127,12.396896824740583 +0.4492629562486531,11.826235561965117 +0.4231956621656814,12.70969615281182 +0.4260110255624409,12.61169539550636 +0.4360360682789106,12.267914605335896 +0.4125213465003683,13.08727808602226 +0.450470108761601,11.786575306370745 +0.4876060042997696,10.615756651653792 +0.4908979301677585,10.51630868789057 +0.4587243100315409,11.51820342434262 +0.5704831274082749,8.295640522268213 +0.4553441813260573,11.627514272601507 +0.4657465328689005,11.293661971804736 +0.4683295087803038,11.211919829332222 +0.4520809402907148,11.73381763799156 +0.5000346708631205,10.243746079373402 +0.5085848916162538,9.993154120928066 +0.5228294219997456,9.584882322246358 +0.4691140758758154,11.187180277017104 +0.4787497272744716,10.886671689046084 +0.434804245355129,12.30972813524587 +0.4641517670976008,11.344357384651474 +0.4339384994613965,12.339186333442564 +0.6005169205713535,7.537315624447977 +0.4370183518156144,12.234656115956469 +0.4305835790125141,12.453899984962744 +0.4347026661463422,12.313181469174893 +0.5433923511588713,9.014720581786882 +0.4798902024134627,10.851504528879776 +0.4772717928487283,10.932369419247197 +0.5045202274456829,10.111752642741116 +0.49267350178682,10.46294577272623 +0.4247534809146396,12.655389329953554 +0.4097377054667908,13.187350185694712 +0.4242418489718387,12.67320323728016 +0.4455439519222082,11.949094467541858 +0.4164911109527965,12.94572681033115 +0.4202148872944709,12.814167872110106 +0.4079823371945343,13.250805946458174 +0.4247088481991763,12.656942489151213 +0.4286604971064608,12.520058956678286 +0.5602592911209706,8.56292197534269 +0.4866227922111371,10.645589394251514 +0.5011797181157777,10.209939338692012 +0.4299381947708539,12.476069865915491 +0.4258708989010308,12.616557767281632 +0.4457176954959773,11.943331975697246 +0.6093381621186634,7.321784078833686 +0.6005169205713535,7.537315624447977 +0.4762518569643057,10.963988435564955 +0.4778426276925917,10.914702455798167 +0.4588028005201544,11.515674680055392 +0.5479707583928451,8.890711216805549 +0.6235286115848476,6.981527939949772 +0.5447420887855449,8.978053714399207 +0.5863710204253532,7.889644487409445 +0.5476946402126041,8.898160660660661 +0.6308709130086646,6.808503251855285 +0.5666043130481949,8.396476056378761 +0.5518913713276599,8.785339429762216 +0.5734716110471646,8.218416962870727 +0.6564854045986197,6.220267957737638 +0.5883237401888561,7.840505966888804 +0.4470008730435425,11.90084270574037 +0.4336235110036997,12.349918833980194 +0.4871834245794994,10.628571239837322 +0.5636945707580261,8.472573308234635 +0.5573164573430773,8.640760850869205 +0.5442958989871955,8.990164809600179 +0.6097753835582131,7.311182657428219 +0.6046107796810654,7.436898384493674 +0.5577895801048655,8.628218917547787 +0.5421555184328466,9.048400339831302 +0.5369372394278203,9.191348539336696 +0.536954888840979,9.190862718209694 +0.5529029623530117,8.7582730334052 +0.5384494322521248,9.149781451807192 +0.5583708865746004,8.61282371716642 +0.5455957287766852,8.954910666608171 +0.5362388629434294,9.210585012986094 +0.5501908632943854,8.830950663247148 +0.5857412835752976,7.90552617726706 +0.4271295773590509,12.572939076372768 +0.4398745512996735,12.138372963051667 +0.4141735336588391,13.028200688041071 +0.4106979150489633,13.152753976657166 +0.4212068846336657,12.77931779450314 +0.5240809898145284,9.549543517160709 +0.5404479755782682,9.0950243187968 +0.4233347292447759,12.70484004221792 +0.4199337244010109,12.82406043209845 +0.4157757837542157,12.971133554335978 +0.4505303099473423,11.784600216600907 +0.513044759865707,9.86411004109984 +0.4286478787739295,12.52049403925086 +0.4206780202376405,12.79788721930682 +0.4121478925271293,13.100664495487148 +0.5220657977885085,9.606485309572678 +0.5328625539826615,9.303938706724232 +0.554826234350534,8.706949762301122 +0.5586244622720604,8.606113090817145 +0.4872161826651791,10.627577464531637 +0.4134954670694136,13.052417810603275 +0.5046215731788667,10.108783985474826 +0.4245207918765598,12.66348839250865 +0.4229056804497161,12.719827216245658 +0.4178160676909468,12.898782510155709 +0.4739140830572343,11.036717953863697 +0.5188912894760958,9.696632412627128 +0.5614870705022679,8.530567629311125 +0.4685779975572959,11.204079814999137 +0.4746506978805993,11.013762793448263 +0.5137125828681638,9.84488353349616 +0.4230671823893701,12.714183981681913 +0.4258328361393589,12.617878815076612 +0.4245092347181123,12.663890771042778 +0.4648585551436993,11.321868105959524 +0.4461357810646956,11.929474679960224 +0.4611498971672447,11.440256993816996 +0.4296176801570608,12.487092376622126 +0.4599111188187409,11.480013869995132 +0.430009310398434,12.4736253104623 +0.4259365991178309,12.614277781538975 +0.4835677328651963,10.738672495420516 +0.4506848338928537,11.779531779068089 +0.4438229628988064,12.006295577942518 +0.5389158913754177,9.136983000747769 +0.5325831289480442,9.311691189244554 +0.5161362577813872,9.775315701167548 +0.4374043494576231,12.221607331955925 +0.5129352758439651,9.867264454581482 +0.5416472751610004,9.062262413106629 +0.55079356767813,8.814768745013298 +0.6129016051580365,7.235601114484312 +0.539495846704112,9.121085942518391 +0.5638514997472411,8.4684592003996 +0.3970927663513635,13.650665652340557 +0.4054734989559816,13.341974873653983 +0.402042504255376,13.467571596932572 +0.416435640917644,12.947695414575648 +0.400593020505336,13.520954505375895 +0.3970927663513635,13.650665652340557 +0.3981075353597885,13.612943394339036 +0.4103077097097941,13.166803251030702 +0.3870113205341511,14.030749857138698 +0.4254541509690909,12.63102831140774 +0.4427458990720113,12.04220727810862 +0.4198986812808817,12.825293868967083 +0.4254541509690909,12.63102831140774 diff --git a/pmml-h2o/src/test/resources/main.py b/pmml-h2o/src/test/resources/main.py index abbe14a..ca3b4f1 100644 --- a/pmml-h2o/src/test/resources/main.py +++ b/pmml-h2o/src/test/resources/main.py @@ -1,5 +1,6 @@ from h2o import H2OFrame from h2o.automl import H2OAutoML +from h2o.estimators.extended_isolation_forest import H2OExtendedIsolationForestEstimator from h2o.estimators.gbm import H2OGradientBoostingEstimator from h2o.estimators.glm import H2OGeneralizedLinearEstimator from h2o.estimators.isolation_forest import H2OIsolationForestEstimator @@ -203,4 +204,5 @@ def build_housing(df, estimator, name): if "Housing" in datasets: housing_df = load_housing("Housing") + build_housing(housing_df, H2OExtendedIsolationForestEstimator(ntrees = 17, extension_level = 4, seed = 42), "ExtendedIsolationForestHousing") build_housing(housing_df, H2OIsolationForestEstimator(ntrees = 17, max_depth = 11, seed = 42), "IsolationForestHousing") diff --git a/pmml-h2o/src/test/resources/mojo/ExtendedIsolationForestHousing.zip b/pmml-h2o/src/test/resources/mojo/ExtendedIsolationForestHousing.zip new file mode 100644 index 0000000..83cad2a Binary files /dev/null and b/pmml-h2o/src/test/resources/mojo/ExtendedIsolationForestHousing.zip differ