|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--com.ibm.iminer.scoring.Scorer
|
+--com.ibm.iminer.scoring.RecordScorer
This Java Bean is used to perform scoring on a single data record. The record
is a set of (field name, value) pairs and must be defined by the user.
The computed result can be accessed through a set of getXXX() methods.
Before calling the score(Map) method, the following needs to
be specified:
// 1. Constructor
RecordScorer recordScorer = new RecordScorer();
try {
// 2. Specify the resources: the used model as a pmml file
recordScorer.openModel( "MyClusterModel.pmml" );
// 3. Get the mining fields which are used by the model.
String[] fields = recordScorer.getMiningFields();
// 4. Associate values to the mining fields.
// Let "fields" contain three values, the first two of type numerical,
// the third of type categorical. The data type can also be checked using the
// methods isCategoricalField( String ) and isNumericalField( String ).
Hashtable record = new Hashtable();
record.put( fields[0], new Double(10.0) );
record.put( fields[1], new Integer(5) );
record.put( fields[2], "male" );
// 5. Do scoring
recordScorer.score( record );
// 6. Access results
int clusterID = recordScorer.getClusterID();
double clusterQuality = recordScorer.getClusterQuality();
} catch ( Exception e ) {
e.printStackTrace();
}
| Fields inherited from class com.ibm.iminer.scoring.Scorer |
|---|
CLASSIFICATION_TYPE, CLUSTER_ID, CLUSTER_QUALITY, CLUSTER_SCORE, CLUSTERING_TYPE, CONFIDENCE, PREDICTED_CLASS, PREDICTED_VALUE, RBF_REGION_ID, REGRESSION_TYPE, UNDEFINED_TYPE |
| Constructor Summary | |
|---|---|
RecordScorer()
Default constructor. |
|
RecordScorer(java.sql.Connection connection,
java.lang.String table,
java.lang.String keyColumn,
java.lang.String modelColumn,
java.lang.String modelKey)
Initializes the actual RecordScorer with the mining model
that is used for scoring. |
|
RecordScorer(java.lang.String pathname)
Initializes the actual RecordScorer with the mining model
that is used for scoring. |
|
| Method Summary | |
|---|---|
int |
getClusterID()
Returns the cluster ID. |
double |
getClusterQuality()
Returns the cluster quality. |
double |
getClusterScore()
Returns the cluster score. |
double |
getConfidence()
Returns the confidence. |
java.lang.String |
getPredictedClass()
Returns the class label. |
double |
getPredictedValue()
Returns the predicted value. |
int |
getRBFRegionID()
Returns the RBF region ID. |
void |
openModel(java.sql.Connection connection,
java.lang.String table,
java.lang.String keyColumn,
java.lang.String modelColumn,
java.lang.String modelKey)
Sets the mining model used for scoring. |
void |
openModel(java.lang.String modelFile)
Sets the mining model used for scoring. |
void |
score(java.util.Map record)
Scores a single record. |
void |
setModelFile(java.lang.String modelFile)
Deprecated. |
| Methods inherited from class com.ibm.iminer.scoring.Scorer |
|---|
getCategoricalFields, getFieldNames, getModelType, getNumericalFields, getResultIdentifiers, isCategoricalField, isField, isNumericalField |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public RecordScorer()
public RecordScorer(java.lang.String pathname)
throws ModelException
RecordScorer with the mining model
that is used for scoring. The mining model is read from a file.pathname - the path of the file that contains the mining model in PMML
format
public RecordScorer(java.sql.Connection connection,
java.lang.String table,
java.lang.String keyColumn,
java.lang.String modelColumn,
java.lang.String modelKey)
throws ModelException,
java.sql.SQLException
RecordScorer with the mining model
that is used for scoring. The mining model is read from the database.connection - JDBC connection used to access the databasetable - Name of the table containing the model. The table can be qualified
by a schema name.keyColumn - This column contains a key that identifies the row of the table
that contains the model. The key must be a character string.modelColumn - This column contains the model (as BLOB)modelKey - The key used to identify the model in the table.| Method Detail |
public double getConfidence()
throws ResultException
Double.NaN indicates, that the
confidence couldn't be computed by the scoring algorithm.ResultException - thrown if the CONFIDENCE
is not computed due to a model type not equal to
Scorer.CLASSIFICATION_TYPE.
public int getClusterID()
throws ResultException
score( Map ) method).ResultException - thrown if the CLUSTER_ID
is not computed due to a model type not equal to
Scorer.CLUSTERING_TYPE.
public double getClusterQuality()
throws ResultException
Double.NaN indicates,
that the cluster quality couldn't be computed by the scoring algorithm.ResultException - thrown if the CLUSTER_QUALITY
is not computed due to a model type not equal to Scorer.CLUSTERING_TYPE.
public double getClusterScore()
throws ResultException
Double.NaN indicates,
that the cluster score couldn't be computed by the scoring algorithm.ResultException - thrown if the CLUSTER_SCORE
is not computed due to a model type not equal to Scorer.CLUSTERING_TYPE.
public java.lang.String getPredictedClass()
throws ResultException
Double.NaN indicates,
that the class label couldn't be computed by the scoring algorithm.ResultException - thrown if the PREDICTED_CLASS
is not computed by scoring due to a model type that is not
equal to Scorer.CLASSIFICATION_TYPE.
public double getPredictedValue()
throws ResultException
Double.NaN indicates, that the predicted value couldn't be
computed by the scoring algorithm.ResultException - thrown if the PREDICTED_VALUE
is not computed by scoring due to a model type that is not
equal to Scorer.REGRESSION_TYPE.
public int getRBFRegionID()
throws ResultException
-1 indicates, that value couldn't be computed by
the scoring algorithm.ResultException - thrown if the RBF_REGION_ID
is not computed by scoring due to a model type that is not
equal to Scorer.REGRESSION_TYPE.
public void openModel(java.lang.String modelFile)
throws ModelException
modelFile is null or "", the model is not set and the
previous set model remains unchanged.modelFile - the path of the file that contains the mining model in PMML
formatModelException - thrown if something is wrong with the supplied input
parameter modelFile, e.g. the specified file is not found or unspecified,
an IO error occured, the specified file is not in the expected PMML format;
public void openModel(java.sql.Connection connection,
java.lang.String table,
java.lang.String keyColumn,
java.lang.String modelColumn,
java.lang.String modelKey)
throws ModelException,
java.sql.SQLException
connection - JDBC connection used to access the databasetable - Name of the table containing the model. The table can be qualified
by a schema name.keyColumn - This column contains a key that identifies the row of the table
that contains the model. The key must be a character string.modelColumn - This column contains the model (as BLOB)modelKey - The key used to identify the model in the table.
public void setModelFile(java.lang.String modelFile)
throws ModelException
modelFile - the path of the file that contains the mining model in PMML
format
public void score(java.util.Map record)
throws RecordException,
ModelException
record contains (key, value) pairs, whereat the
keys are the names of the mining fields, which are used by the mining model for
the scoring computation, and the values are the values of these mining fields
in the actual record. Field names in the Map which are unknown for the
mining model, are ignored.
The following must hold for a valid record: categorical
fields must have String objects associated as values, and
numerical fields must have values associated to it, which can be casted to
Double.
modelFile must be set and the
loadModel() must be called explicitly.record - The record to be scoredRecordException - thrown if the supplied input parameter record
does not fit to the loaded mining model.ModelException - thrown if no mining model was loaded yet
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||