@@ -147,18 +147,18 @@ public void process(Aggregations aggs) {
147
147
long actualClassDocCount = bucket .getDocCount ();
148
148
Filters subAgg = bucket .getAggregations ().get (STEP_2_AGGREGATE_BY_PREDICTED_CLASS );
149
149
List <PredictedClass > predictedClasses = new ArrayList <>();
150
- long otherPredictedClassCount = 0 ;
150
+ long otherPredictedClassDocCount = 0 ;
151
151
for (Filters .Bucket subBucket : subAgg .getBuckets ()) {
152
152
String predictedClass = subBucket .getKeyAsString ();
153
153
long docCount = subBucket .getDocCount ();
154
154
if (OTHER_BUCKET_KEY .equals (predictedClass )) {
155
- otherPredictedClassCount = docCount ;
155
+ otherPredictedClassDocCount = docCount ;
156
156
} else {
157
157
predictedClasses .add (new PredictedClass (predictedClass , docCount ));
158
158
}
159
159
}
160
160
predictedClasses .sort (comparing (PredictedClass ::getPredictedClass ));
161
- actualClasses .add (new ActualClass (actualClass , actualClassDocCount , predictedClasses , otherPredictedClassCount ));
161
+ actualClasses .add (new ActualClass (actualClass , actualClassDocCount , predictedClasses , otherPredictedClassDocCount ));
162
162
}
163
163
result = new Result (actualClasses , Math .max (cardinalityAgg .getValue () - size , 0 ));
164
164
}
@@ -214,8 +214,9 @@ public static Result fromXContent(XContentParser parser) {
214
214
return PARSER .apply (parser , null );
215
215
}
216
216
217
- // Immutable
217
+ /** List of actual classes. */
218
218
private final List <ActualClass > actualClasses ;
219
+ /** Number of actual classes that were not included in the confusion matrix because there were too many of them. */
219
220
private final long otherActualClassCount ;
220
221
221
222
public Result (List <ActualClass > actualClasses , long otherActualClassCount ) {
@@ -281,7 +282,7 @@ public static class ActualClass implements ToXContentObject, Writeable {
281
282
private static final ParseField ACTUAL_CLASS = new ParseField ("actual_class" );
282
283
private static final ParseField ACTUAL_CLASS_DOC_COUNT = new ParseField ("actual_class_doc_count" );
283
284
private static final ParseField PREDICTED_CLASSES = new ParseField ("predicted_classes" );
284
- private static final ParseField OTHER_PREDICTED_CLASS_COUNT = new ParseField ("other_predicted_class_count " );
285
+ private static final ParseField OTHER_PREDICTED_CLASS_DOC_COUNT = new ParseField ("other_predicted_class_doc_count " );
285
286
286
287
@ SuppressWarnings ("unchecked" )
287
288
private static final ConstructingObjectParser <ActualClass , Void > PARSER =
@@ -294,35 +295,39 @@ public static class ActualClass implements ToXContentObject, Writeable {
294
295
PARSER .declareString (constructorArg (), ACTUAL_CLASS );
295
296
PARSER .declareLong (constructorArg (), ACTUAL_CLASS_DOC_COUNT );
296
297
PARSER .declareObjectArray (constructorArg (), PredictedClass .PARSER , PREDICTED_CLASSES );
297
- PARSER .declareLong (constructorArg (), OTHER_PREDICTED_CLASS_COUNT );
298
+ PARSER .declareLong (constructorArg (), OTHER_PREDICTED_CLASS_DOC_COUNT );
298
299
}
299
300
301
+ /** Name of the actual class. */
300
302
private final String actualClass ;
303
+ /** Number of documents (examples) belonging to the {code actualClass} class. */
301
304
private final long actualClassDocCount ;
305
+ /** List of predicted classes. */
302
306
private final List <PredictedClass > predictedClasses ;
303
- private final long otherPredictedClassCount ;
307
+ /** Number of documents that were not predicted as any of the {@code predictedClasses}. */
308
+ private final long otherPredictedClassDocCount ;
304
309
305
310
public ActualClass (
306
- String actualClass , long actualClassDocCount , List <PredictedClass > predictedClasses , long otherPredictedClassCount ) {
311
+ String actualClass , long actualClassDocCount , List <PredictedClass > predictedClasses , long otherPredictedClassDocCount ) {
307
312
this .actualClass = actualClass ;
308
313
this .actualClassDocCount = actualClassDocCount ;
309
314
this .predictedClasses = Collections .unmodifiableList (predictedClasses );
310
- this .otherPredictedClassCount = otherPredictedClassCount ;
315
+ this .otherPredictedClassDocCount = otherPredictedClassDocCount ;
311
316
}
312
317
313
318
public ActualClass (StreamInput in ) throws IOException {
314
319
this .actualClass = in .readString ();
315
320
this .actualClassDocCount = in .readLong ();
316
321
this .predictedClasses = Collections .unmodifiableList (in .readList (PredictedClass ::new ));
317
- this .otherPredictedClassCount = in .readLong ();
322
+ this .otherPredictedClassDocCount = in .readLong ();
318
323
}
319
324
320
325
@ Override
321
326
public void writeTo (StreamOutput out ) throws IOException {
322
327
out .writeString (actualClass );
323
328
out .writeLong (actualClassDocCount );
324
329
out .writeList (predictedClasses );
325
- out .writeLong (otherPredictedClassCount );
330
+ out .writeLong (otherPredictedClassDocCount );
326
331
}
327
332
328
333
@ Override
@@ -331,7 +336,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
331
336
builder .field (ACTUAL_CLASS .getPreferredName (), actualClass );
332
337
builder .field (ACTUAL_CLASS_DOC_COUNT .getPreferredName (), actualClassDocCount );
333
338
builder .field (PREDICTED_CLASSES .getPreferredName (), predictedClasses );
334
- builder .field (OTHER_PREDICTED_CLASS_COUNT .getPreferredName (), otherPredictedClassCount );
339
+ builder .field (OTHER_PREDICTED_CLASS_DOC_COUNT .getPreferredName (), otherPredictedClassDocCount );
335
340
builder .endObject ();
336
341
return builder ;
337
342
}
@@ -344,12 +349,12 @@ public boolean equals(Object o) {
344
349
return Objects .equals (this .actualClass , that .actualClass )
345
350
&& this .actualClassDocCount == that .actualClassDocCount
346
351
&& Objects .equals (this .predictedClasses , that .predictedClasses )
347
- && this .otherPredictedClassCount == that .otherPredictedClassCount ;
352
+ && this .otherPredictedClassDocCount == that .otherPredictedClassDocCount ;
348
353
}
349
354
350
355
@ Override
351
356
public int hashCode () {
352
- return Objects .hash (actualClass , actualClassDocCount , predictedClasses , otherPredictedClassCount );
357
+ return Objects .hash (actualClass , actualClassDocCount , predictedClasses , otherPredictedClassDocCount );
353
358
}
354
359
}
355
360
0 commit comments