|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwater.Iced
water.Model
public abstract class Model
A Model models reality (hopefully). A model can be used to 'score' a row, or a collection of rows on any compatible dataset - meaning the row has all the columns with the same names as used to build the mode.
Nested Class Summary | |
---|---|
protected static class |
Model.SB
|
Field Summary | |
---|---|
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 Summary | |
---|---|
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 |
Method Summary | |
---|---|
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,
boolean exact)
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. |
protected void |
toJavaInit(javassist.CtClass ct)
|
protected void |
toJavaInit(Model.SB sb)
|
protected void |
toJavaPredictBody(Model.SB sb)
|
Methods inherited from class water.Iced |
---|
clone, frozenType, init, newInstance, read, toDocField, write, writeJSON, writeJSONFields |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public 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
Constructor Detail |
---|
public Model(Key selfKey, Key dataKey, Frame fr)
public Model(Key selfKey, Key dataKey, java.lang.String[] names, java.lang.String[][] domains)
public Model(Key selfKey, Model m)
Method Detail |
---|
public void delete()
public java.lang.String responseName()
public java.lang.String[] classNames()
public boolean isClassifier()
public int nclasses()
public ConfusionMatrix cm()
public Frame score(Frame fr, boolean exact)
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( 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(Model.SB sb)
protected void toJavaInit(javassist.CtClass ct)
protected void toJavaPredictBody(Model.SB sb)
public void testJavaScoring(Frame fr)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |