-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change format of MulticlassConfusionMatrix result to be more self-explanatory #48174
Change format of MulticlassConfusionMatrix result to be more self-explanatory #48174
Conversation
66e1005
to
071cbd7
Compare
071cbd7
to
fa6ab5b
Compare
Pinging @elastic/ml-core (:ml) |
run elasticsearch-ci/packaging-sample-matrix |
4ce3aa3
to
97628e2
Compare
@elasticmachine update branch |
1 similar comment
@elasticmachine update branch |
2fd6087
to
dfecdf6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the new format. It also gives us flexibility to add new fields in the future if we deem them necessary.
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(); | ||
builder.field(PREDICTED_CLASS.getPreferredName(), predictedClass); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the ctor, both of these are nullable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
...ticsearch/client/ml/dataframe/evaluation/classification/MulticlassConfusionMatrixMetric.java
Show resolved
Hide resolved
String actualClass, long actualClassDocCount, List<PredictedClass> predictedClasses, long otherPredictedClassDocCount) { | ||
this.actualClass = actualClass; | ||
this.actualClassDocCount = actualClassDocCount; | ||
this.predictedClasses = Collections.unmodifiableList(predictedClasses); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be nullable? I think it would throw if predictedClasses == null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
this.otherClassesCount = otherClassesCount; | ||
public Result(List<ActualClass> actualClasses, long otherActualClassCount) { | ||
this.actualClasses = Collections.unmodifiableList(Objects.requireNonNull(actualClasses)); | ||
this.otherActualClassCount = otherActualClassCount; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be good to do a otherActualClassCount >= 0
check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
in.readMap(StreamInput::readString, in2 -> in2.readMap(StreamInput::readString, StreamInput::readLong))); | ||
this.otherClassesCount = in.readLong(); | ||
this.actualClasses = Collections.unmodifiableList(in.readList(ActualClass::new)); | ||
this.otherActualClassCount = in.readLong(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.otherActualClassCount = in.readLong(); | |
this.otherActualClassCount = in.readVLong(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeString(actualClass); | ||
out.writeLong(actualClassDocCount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
out.writeLong(actualClassDocCount); | |
out.writeVLong(actualClassDocCount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
||
public PredictedClass(StreamInput in) throws IOException { | ||
this.predictedClass = in.readString(); | ||
this.count = in.readLong(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.count = in.readLong(); | |
this.count = in.readVLong(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeString(predictedClass); | ||
out.writeLong(count); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
out.writeLong(count); | |
out.writeVLong(count); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
private final long count; | ||
|
||
public PredictedClass(String predictedClass, long count) { | ||
this.predictedClass = predictedClass; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
||
public PredictedClass(String predictedClass, long count) { | ||
this.predictedClass = predictedClass; | ||
this.count = count; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
>= 0
check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cc20654
to
9b1c359
Compare
run elasticsearch-ci/packaging-sample-matrix |
9b1c359
to
92a6dd4
Compare
run elasticsearch-ci/packaging-sample-matrix |
Current MulticlassConfusionMatrix result can be confusing to the API user.
They have no means to tell if the outer map is actual or predicted. Similarly for inner map.
This PR fixes that by making the format strict (naming each field).
Relates #46735