public abstract class Model extends Iced
| Modifier and Type | Class and Description |
|---|---|
static class |
Model.GeneratedModel |
| 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.
|
Key |
_selfKey
Key associated with this Model, if any.
|
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.
|
void |
delete()
Called when deleting this model, to cleanup any internal keys
|
static int[] |
getDomainMapping(java.lang.String colName,
java.lang.String[] modelDom,
java.lang.String[] dom,
boolean exact)
Returns a mapping between values domains for a given column.
|
boolean |
isClassifier() |
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 void |
toJavaInit(javassist.CtClass ct) |
protected SB |
toJavaInit(SB sb) |
protected void |
toJavaPredictBody(SB sb,
SB afterSb) |
VariableImportance |
varimp()
Variable importance of individual variables measured by this model.
|
clone, frozenType, init, newInstance, read, toDocField, write, writeJSON, writeJSONFieldspublic static DocGen.FieldDoc[] DOC_FIELDS
public final Key _selfKey
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 void delete()
public java.lang.String responseName()
public java.lang.String[] classNames()
public boolean isClassifier()
public int nclasses()
public ConfusionMatrix cm()
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 colName,
java.lang.String[] modelDom,
java.lang.String[] dom,
boolean 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 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( HashMap row, 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)
public void testJavaScoring(Frame fr)