コード例 #1
0
 public Measurement[] getModelMeasurements() {
   List<Measurement> measurementList = new LinkedList<Measurement>();
   measurementList.add(new Measurement("model training instances", trainingWeightSeenByModel()));
   measurementList.add(new Measurement("model serialized size (bytes)", measureByteSize()));
   Measurement[] modelMeasurements = getModelMeasurementsImpl();
   if (modelMeasurements != null) {
     for (Measurement measurement : modelMeasurements) {
       measurementList.add(measurement);
     }
   }
   // add average of sub-model measurements
   Classifier[] subModels = getSubClassifiers();
   if ((subModels != null) && (subModels.length > 0)) {
     List<Measurement[]> subMeasurements = new LinkedList<Measurement[]>();
     for (Classifier subModel : subModels) {
       if (subModel != null) {
         subMeasurements.add(subModel.getModelMeasurements());
       }
     }
     Measurement[] avgMeasurements =
         Measurement.averageMeasurements(
             subMeasurements.toArray(new Measurement[subMeasurements.size()][]));
     for (Measurement measurement : avgMeasurements) {
       measurementList.add(measurement);
     }
   }
   return measurementList.toArray(new Measurement[measurementList.size()]);
 }
コード例 #2
0
 public void getDescription(StringBuilder out, int indent) {
   StringUtils.appendIndented(out, indent, "Model type: ");
   out.append(this.getClass().getName());
   StringUtils.appendNewline(out);
   Measurement.getMeasurementsDescription(getModelMeasurements(), out, indent);
   StringUtils.appendNewlineIndented(out, indent, "Model description:");
   StringUtils.appendNewline(out);
   if (trainingHasStarted()) {
     getModelDescription(out, indent);
   } else {
     StringUtils.appendIndented(out, indent, "Model has not been trained.");
   }
 }