public abstract class SharedTreeMojoModel extends MojoModel
DrfMojoModel and GbmMojoModel.
See also: `hex.tree.SharedTreeModel` and `hex.tree.TreeVisitor` classes.| Modifier and Type | Class and Description |
|---|---|
static interface |
SharedTreeMojoModel.DecisionPathTracker<T> |
static class |
SharedTreeMojoModel.LeafDecisionPathTracker |
static class |
SharedTreeMojoModel.LeafNodeAssignments |
static class |
SharedTreeMojoModel.StringDecisionPathTracker |
| Modifier and Type | Field and Description |
|---|---|
protected double[] |
_calib_glm_beta
GLM's beta used for calibrating output probabilities using Platt Scaling.
|
protected byte[][] |
_compressed_trees
Array of binary tree data, each tree being a
byte[] array. |
protected byte[][] |
_compressed_trees_aux
Array of auxiliary binary tree data, each being a
byte[] array. |
protected double |
_mojo_version |
protected int |
_ntree_groups
_ntree_groups is the number of trees requested by the user. |
protected int |
_ntrees_per_group |
_balanceClasses, _category, _defaultThreshold, _modelClassDistrib, _nclasses, _nfeatures, _priorClassDistrib, _supervised, _uuid_domains, _names, _offsetColumn, _responseColumn| Modifier | Constructor and Description |
|---|---|
protected |
SharedTreeMojoModel(java.lang.String[] columns,
java.lang.String[][] domains,
java.lang.String responseColumn) |
| Modifier and Type | Method and Description |
|---|---|
SharedTreeGraph |
_computeGraph(int treeToPrint)
Compute a graph of the forest.
|
boolean |
calibrateClassProbabilities(double[] preds)
Subclasses implement calibration of class probabilities.
|
static SharedTreeSubgraph |
computeTreeGraph(int treeNum,
java.lang.String treeName,
byte[] tree,
byte[] auxTreeInfo,
int nclasses,
java.lang.String[] names,
java.lang.String[][] domains) |
static java.lang.String |
getDecisionPath(double leafAssignment) |
java.lang.String[] |
getDecisionPath(double[] row) |
static <T> T |
getDecisionPath(double leafAssignment,
SharedTreeMojoModel.DecisionPathTracker<T> tr) |
java.lang.String[] |
getDecisionPathNames() |
SharedTreeMojoModel.LeafNodeAssignments |
getLeafNodeAssignments(double[] row) |
static int |
getLeafNodeId(double leafAssignment,
byte[] auxTree) |
int |
getNTreeGroups() |
int |
getNTreesPerGroup() |
protected void |
postInit() |
protected void |
scoreAllTrees(double[] row,
double[] preds)
Score all trees and fill in the `preds` array.
|
void |
scoreSingleTree(double[] row,
int index,
double[] preds)
Generates a (per-class) prediction using only a single tree.
|
static double |
scoreTree(byte[] tree,
double[] row,
int nclasses,
boolean computeLeafAssignment,
java.lang.String[][] domains)
Highly efficient (critical path) tree scoring
Given a tree (in the form of a byte array) and the row of input data, compute either this tree's
predicted value when `computeLeafAssignment` is false, or the the decision path within the tree (but no more
than 64 levels) when `computeLeafAssignment` is true.
|
static double |
scoreTree0(byte[] tree,
double[] row,
int nclasses,
boolean computeLeafAssignment)
SET IN STONE FOR MOJO VERSION "1.00" - DO NOT CHANGE
|
static double |
scoreTree1(byte[] tree,
double[] row,
int nclasses,
boolean computeLeafAssignment)
SET IN STONE FOR MOJO VERSION "1.10" - DO NOT CHANGE
|
void |
scoreTreeRange(double[] row,
int fromIndex,
int toIndex,
double[] preds)
Generates (partial, per-class) predictions using only trees from a given range.
|
static java.lang.String |
treeName(int groupIndex,
int classIndex,
java.lang.String[] domainValues) |
abstract double[] |
unifyPreds(double[] row,
double offset,
double[] preds)
Transforms tree predictions into the final model predictions.
|
getModelCategory, getUUID, isSupervised, load, load, nclasses, nfeaturesbitSetContains, bitSetIsInRange, convertDouble2Float, correctProbabilities, createAuxKey, GBM_rescale, getColIdx, getDomainValues, getDomainValues, getDomainValues, getHeader, getModelCategories, getNames, getNumClasses, getNumCols, getNumResponseClasses, getPrediction, getPredsSize, getPredsSize, getResponseIdx, getResponseName, GLM_identityInv, GLM_inverseInv, GLM_logInv, GLM_logitInv, GLM_ologitInv, GLM_tweedieInv, img2pixels, isAutoEncoder, isClassifier, KMeans_closest, KMeans_distance, KMeans_distance, KMeans_distances, Kmeans_preprocessData, Kmeans_preprocessData, KMeans_simplex, log_rescale, mapEnum, score0, score0, setCats, setCats, setInput, setInputprotected double _mojo_version
protected int _ntree_groups
_ntree_groups is the number of trees requested by the user. For
binomial case or regression this is also the total number of trees
trained; however in multinomial case each requested "tree" is actually
represented as a group of trees, with _ntrees_per_group trees
in each group. Each of these individual trees assesses the likelihood
that a given observation belongs to class A, B, C, etc. of a
multiclass response.protected int _ntrees_per_group
protected byte[][] _compressed_trees
byte[] array. The
trees are logically grouped into a rectangular grid of dimensions
_ntree_groups x _ntrees_per_group, however physically
they are stored as 1-dimensional list, and an [i, j] logical
tree is mapped to the index treeIndex(int, int).protected byte[][] _compressed_trees_aux
byte[] array.protected double[] _calib_glm_beta
protected SharedTreeMojoModel(java.lang.String[] columns,
java.lang.String[][] domains,
java.lang.String responseColumn)
protected void postInit()
public final int getNTreeGroups()
public final int getNTreesPerGroup()
public static double scoreTree(byte[] tree,
double[] row,
int nclasses,
boolean computeLeafAssignment,
java.lang.String[][] domains)
public static <T> T getDecisionPath(double leafAssignment,
SharedTreeMojoModel.DecisionPathTracker<T> tr)
public static java.lang.String getDecisionPath(double leafAssignment)
public static int getLeafNodeId(double leafAssignment,
byte[] auxTree)
public SharedTreeGraph _computeGraph(int treeToPrint)
public static SharedTreeSubgraph computeTreeGraph(int treeNum, java.lang.String treeName, byte[] tree, byte[] auxTreeInfo, int nclasses, java.lang.String[] names, java.lang.String[][] domains)
public static java.lang.String treeName(int groupIndex,
int classIndex,
java.lang.String[] domainValues)
protected void scoreAllTrees(double[] row,
double[] preds)
public abstract double[] unifyPreds(double[] row,
double offset,
double[] preds)
row - input row.offset - offset.preds - final output, same structure as of GenModel.score0(double[], double[]).public final void scoreSingleTree(double[] row,
int index,
double[] preds)
row - input rowindex - index of the tree (0..N-1)preds - array of partial predictions.public final void scoreTreeRange(double[] row,
int fromIndex,
int toIndex,
double[] preds)
row - input rowfromIndex - low endpoint (inclusive) of the tree rangetoIndex - high endpoint (exclusive) of the tree rangepreds - array of partial predictions.
To get final predictions pass the result to unifyPreds(double[], double, double[]).public java.lang.String[] getDecisionPathNames()
public SharedTreeMojoModel.LeafNodeAssignments getLeafNodeAssignments(double[] row)
public java.lang.String[] getDecisionPath(double[] row)
public static double scoreTree0(byte[] tree,
double[] row,
int nclasses,
boolean computeLeafAssignment)
tree - row - nclasses - computeLeafAssignment - public static double scoreTree1(byte[] tree,
double[] row,
int nclasses,
boolean computeLeafAssignment)
tree - row - nclasses - computeLeafAssignment - public boolean calibrateClassProbabilities(double[] preds)
GenModelcalibrateClassProbabilities in class GenModel