public abstract class Model extends Lockable<Model>
Modifier and Type | Field and Description |
---|---|
Key |
_dataKey
Dataset key used to *build* the model, for models for which this makes
sense, or null otherwise.
|
java.lang.String[][] |
_domains
Categorical/factor/enum mappings, per column.
|
java.lang.String[] |
_names
Columns used in the model and are used to match up with scoring data
columns.
|
static DocGen.FieldDoc[] |
DOC_FIELDS |
Constructor and Description |
---|
Model(Key selfKey,
Key dataKey,
Frame fr)
Full constructor from frame: Strips out the Vecs to just the names needed
to match columns later for future datasets.
|
Model(Key selfKey,
Key dataKey,
java.lang.String[] names,
java.lang.String[][] domains)
Full constructor
|
Model(Key selfKey,
Model m)
Simple shallow copy constructor to a new Key
|
Modifier and Type | Method and Description |
---|---|
Frame[] |
adapt(Frame fr,
boolean exact)
Build an adapted Frame from the given Frame.
|
java.lang.String[] |
classNames() |
ConfusionMatrix |
cm()
For classifiers, confusion matrix on validation set.
|
Futures |
delete_impl(Futures fs)
Remove any Model internal Keys
|
java.lang.String |
errStr() |
static int[][] |
getDomainMapping(java.lang.String[] modelDom,
java.lang.String[] colDom,
boolean exact)
Returns a mapping between values of model domains (
modelDom ) and given column domain. |
static int[][] |
getDomainMapping(java.lang.String colName,
java.lang.String[] modelDom,
java.lang.String[] colDom,
boolean exact)
Returns a mapping for given column according to given
modelDom . |
static int |
getPrediction(float[] preds,
double[] data)
Utility function to get a best prediction from an array of class
prediction distribution.
|
static int |
getPrediction(float[] preds,
int row) |
boolean |
isClassifier() |
double |
mse()
Returns mse for validation set.
|
int |
nclasses() |
java.lang.String |
responseName() |
double |
score(double[] data) |
Frame |
score(Frame fr)
Bulk score the frame 'fr', producing a Frame result; the 1st Vec is the
predicted class, the remaining Vecs are the probability distributions.
|
float[] |
score(Frame fr,
boolean exact,
int row)
Single row scoring, on a compatible Frame.
|
float[] |
score(int[][][] map,
double[] row,
float[] preds)
Single row scoring, on a compatible set of data, given an adaption vector
|
float[] |
score(java.lang.String[] names,
java.lang.String[][] domains,
boolean exact,
double[] row)
Single row scoring, on a compatible set of data.
|
protected float[] |
score0(Chunk[] chks,
int row_in_chunk,
double[] tmp,
float[] preds)
Bulk scoring API for one row.
|
protected abstract float[] |
score0(double[] data,
float[] preds)
Subclasses implement the scoring logic.
|
void |
testJavaScoring(Frame fr) |
java.lang.String |
toJava()
Return a String which is a valid Java program representing a class that
implements the Model.
|
SB |
toJava(SB sb) |
protected java.lang.String |
toJavaDefaultMaxIters() |
protected void |
toJavaInit(javassist.CtClass ct) |
protected SB |
toJavaInit(SB sb,
SB fileContextSB) |
protected void |
toJavaPredictBody(SB bodySb,
SB classCtxSb,
SB fileCtxSb) |
protected SB |
toJavaSuper(SB sb)
Generate implementation for super class.
|
VariableImportance |
varimp()
Variable importance of individual variables measured by this model.
|
delete_and_lock, delete, delete, delete, delete, read_lock, read_lock, unlock, update, write_lock
clone, frozenType, init, newInstance, read, toDocField, write, writeJSON, writeJSONFields
public static DocGen.FieldDoc[] DOC_FIELDS
public final Key _dataKey
public final java.lang.String[] _names
public final java.lang.String[][] _domains
public Model(Key selfKey, Key dataKey, Frame fr)
public Model(Key selfKey, Key dataKey, java.lang.String[] names, java.lang.String[][] domains)
public Futures delete_impl(Futures fs)
delete_impl
in class Lockable<Model>
public java.lang.String responseName()
public java.lang.String[] classNames()
public boolean isClassifier()
public int nclasses()
public ConfusionMatrix cm()
public double mse()
public VariableImportance varimp()
public Frame score(Frame fr)
public final float[] score(Frame fr, boolean exact, int row)
public final float[] score(java.lang.String[] names, java.lang.String[][] domains, boolean exact, double[] row)
public final float[] score(int[][][] map, double[] row, float[] preds)
public Frame[] adapt(Frame fr, boolean exact)
public static int[][] getDomainMapping(java.lang.String[] modelDom, java.lang.String[] colDom, boolean exact)
modelDom
) and given column domain.public static int[][] getDomainMapping(java.lang.String colName, java.lang.String[] modelDom, java.lang.String[] colDom, boolean exact)
modelDom
.
In this case, modelDom
iscolName
- name of column which is mapped, can be null.modelDom
- exact
- protected float[] score0(Chunk[] chks, int row_in_chunk, double[] tmp, float[] preds)
protected abstract float[] score0(double[] data, float[] preds)
public double score(double[] data)
public static int getPrediction(float[] preds, double[] data)
preds
- an array of prediction distribution. Length of arrays is equal to a number of classes+1.public static int getPrediction(float[] preds, int row)
public java.lang.String toJava()
class UUIDxxxxModel { public static final String NAMES[] = { ....column names... } public static final String DOMAINS[][] = { ....domain names... } // Pass in data in a double[], pre-aligned to the Model's requirements. // Jam predictions into the preds[] array; preds[0] is reserved for the // main prediction (class for classifiers or value for regression), // and remaining columns hold a probability distribution for classifiers. float[] predict( double data[], float preds[] ); double[] map( HashMaprow, double data[] ); // Does the mapping lookup for every row, no allocation float[] predict( HashMap row, double data[], float preds[] ); // Allocates a double[] for every row float[] predict( HashMap row, float preds[] ); // Allocates a double[] and a float[] for every row float[] predict( HashMap row ); }
protected void toJavaInit(javassist.CtClass ct)
protected java.lang.String toJavaDefaultMaxIters()
public void testJavaScoring(Frame fr)