
software.amazon.awssdk.services.glue.model.FindMatchesMetrics Maven / Gradle / Ivy
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.glue.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* The evaluation metrics for the find matches algorithm. The quality of your machine learning transform is measured by
* getting your transform to predict some matches and comparing the results to known matches from the same dataset. The
* quality metrics are based on a subset of your data, so they are not precise.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class FindMatchesMetrics implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField AREA_UNDER_PR_CURVE_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("AreaUnderPRCurve").getter(getter(FindMatchesMetrics::areaUnderPRCurve))
.setter(setter(Builder::areaUnderPRCurve))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AreaUnderPRCurve").build()).build();
private static final SdkField PRECISION_FIELD = SdkField. builder(MarshallingType.DOUBLE)
.memberName("Precision").getter(getter(FindMatchesMetrics::precision)).setter(setter(Builder::precision))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Precision").build()).build();
private static final SdkField RECALL_FIELD = SdkField. builder(MarshallingType.DOUBLE).memberName("Recall")
.getter(getter(FindMatchesMetrics::recall)).setter(setter(Builder::recall))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Recall").build()).build();
private static final SdkField F1_FIELD = SdkField. builder(MarshallingType.DOUBLE).memberName("F1")
.getter(getter(FindMatchesMetrics::f1)).setter(setter(Builder::f1))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("F1").build()).build();
private static final SdkField CONFUSION_MATRIX_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("ConfusionMatrix")
.getter(getter(FindMatchesMetrics::confusionMatrix)).setter(setter(Builder::confusionMatrix))
.constructor(ConfusionMatrix::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ConfusionMatrix").build()).build();
private static final SdkField> COLUMN_IMPORTANCES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("ColumnImportances")
.getter(getter(FindMatchesMetrics::columnImportances))
.setter(setter(Builder::columnImportances))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ColumnImportances").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ColumnImportance::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(AREA_UNDER_PR_CURVE_FIELD,
PRECISION_FIELD, RECALL_FIELD, F1_FIELD, CONFUSION_MATRIX_FIELD, COLUMN_IMPORTANCES_FIELD));
private static final long serialVersionUID = 1L;
private final Double areaUnderPRCurve;
private final Double precision;
private final Double recall;
private final Double f1;
private final ConfusionMatrix confusionMatrix;
private final List columnImportances;
private FindMatchesMetrics(BuilderImpl builder) {
this.areaUnderPRCurve = builder.areaUnderPRCurve;
this.precision = builder.precision;
this.recall = builder.recall;
this.f1 = builder.f1;
this.confusionMatrix = builder.confusionMatrix;
this.columnImportances = builder.columnImportances;
}
/**
*
* The area under the precision/recall curve (AUPRC) is a single number measuring the overall quality of the
* transform, that is independent of the choice made for precision vs. recall. Higher values indicate that you have
* a more attractive precision vs. recall tradeoff.
*
*
* For more information, see Precision and recall
* in Wikipedia.
*
*
* @return The area under the precision/recall curve (AUPRC) is a single number measuring the overall quality of the
* transform, that is independent of the choice made for precision vs. recall. Higher values indicate that
* you have a more attractive precision vs. recall tradeoff.
*
* For more information, see Precision and
* recall in Wikipedia.
*/
public final Double areaUnderPRCurve() {
return areaUnderPRCurve;
}
/**
*
* The precision metric indicates when often your transform is correct when it predicts a match. Specifically, it
* measures how well the transform finds true positives from the total true positives possible.
*
*
* For more information, see Precision and recall
* in Wikipedia.
*
*
* @return The precision metric indicates when often your transform is correct when it predicts a match.
* Specifically, it measures how well the transform finds true positives from the total true positives
* possible.
*
* For more information, see Precision and
* recall in Wikipedia.
*/
public final Double precision() {
return precision;
}
/**
*
* The recall metric indicates that for an actual match, how often your transform predicts the match. Specifically,
* it measures how well the transform finds true positives from the total records in the source data.
*
*
* For more information, see Precision and recall
* in Wikipedia.
*
*
* @return The recall metric indicates that for an actual match, how often your transform predicts the match.
* Specifically, it measures how well the transform finds true positives from the total records in the
* source data.
*
* For more information, see Precision and
* recall in Wikipedia.
*/
public final Double recall() {
return recall;
}
/**
*
* The maximum F1 metric indicates the transform's accuracy between 0 and 1, where 1 is the best accuracy.
*
*
* For more information, see F1 score in Wikipedia.
*
*
* @return The maximum F1 metric indicates the transform's accuracy between 0 and 1, where 1 is the best
* accuracy.
*
* For more information, see F1 score in Wikipedia.
*/
public final Double f1() {
return f1;
}
/**
*
* The confusion matrix shows you what your transform is predicting accurately and what types of errors it is
* making.
*
*
* For more information, see Confusion matrix in
* Wikipedia.
*
*
* @return The confusion matrix shows you what your transform is predicting accurately and what types of errors it
* is making.
*
* For more information, see Confusion matrix
* in Wikipedia.
*/
public final ConfusionMatrix confusionMatrix() {
return confusionMatrix;
}
/**
* For responses, this returns true if the service returned a value for the ColumnImportances property. This DOES
* NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasColumnImportances() {
return columnImportances != null && !(columnImportances instanceof SdkAutoConstructList);
}
/**
*
* A list of ColumnImportance
structures containing column importance metrics, sorted in order of
* descending importance.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasColumnImportances} method.
*
*
* @return A list of ColumnImportance
structures containing column importance metrics, sorted in order
* of descending importance.
*/
public final List columnImportances() {
return columnImportances;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(areaUnderPRCurve());
hashCode = 31 * hashCode + Objects.hashCode(precision());
hashCode = 31 * hashCode + Objects.hashCode(recall());
hashCode = 31 * hashCode + Objects.hashCode(f1());
hashCode = 31 * hashCode + Objects.hashCode(confusionMatrix());
hashCode = 31 * hashCode + Objects.hashCode(hasColumnImportances() ? columnImportances() : null);
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof FindMatchesMetrics)) {
return false;
}
FindMatchesMetrics other = (FindMatchesMetrics) obj;
return Objects.equals(areaUnderPRCurve(), other.areaUnderPRCurve()) && Objects.equals(precision(), other.precision())
&& Objects.equals(recall(), other.recall()) && Objects.equals(f1(), other.f1())
&& Objects.equals(confusionMatrix(), other.confusionMatrix())
&& hasColumnImportances() == other.hasColumnImportances()
&& Objects.equals(columnImportances(), other.columnImportances());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public final String toString() {
return ToString.builder("FindMatchesMetrics").add("AreaUnderPRCurve", areaUnderPRCurve()).add("Precision", precision())
.add("Recall", recall()).add("F1", f1()).add("ConfusionMatrix", confusionMatrix())
.add("ColumnImportances", hasColumnImportances() ? columnImportances() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "AreaUnderPRCurve":
return Optional.ofNullable(clazz.cast(areaUnderPRCurve()));
case "Precision":
return Optional.ofNullable(clazz.cast(precision()));
case "Recall":
return Optional.ofNullable(clazz.cast(recall()));
case "F1":
return Optional.ofNullable(clazz.cast(f1()));
case "ConfusionMatrix":
return Optional.ofNullable(clazz.cast(confusionMatrix()));
case "ColumnImportances":
return Optional.ofNullable(clazz.cast(columnImportances()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function