All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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 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 getter(Function g) { return obj -> g.apply((FindMatchesMetrics) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* 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. *

* * @param areaUnderPRCurve * 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 Returns a reference to this object so that method calls can be chained together. */ Builder areaUnderPRCurve(Double 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. *

* * @param precision * 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 Returns a reference to this object so that method calls can be chained together. */ Builder precision(Double 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. *

* * @param recall * 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 Returns a reference to this object so that method calls can be chained together. */ Builder recall(Double 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. *

* * @param f1 * 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 Returns a reference to this object so that method calls can be chained together. */ Builder f1(Double 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. *

* * @param confusionMatrix * 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 Returns a reference to this object so that method calls can be chained together. */ Builder confusionMatrix(ConfusionMatrix confusionMatrix); /** *

* 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. *

* This is a convenience method that creates an instance of the {@link ConfusionMatrix.Builder} avoiding the * need to create one manually via {@link ConfusionMatrix#builder()}. * *

* When the {@link Consumer} completes, {@link ConfusionMatrix.Builder#build()} is called immediately and its * result is passed to {@link #confusionMatrix(ConfusionMatrix)}. * * @param confusionMatrix * a consumer that will call methods on {@link ConfusionMatrix.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #confusionMatrix(ConfusionMatrix) */ default Builder confusionMatrix(Consumer confusionMatrix) { return confusionMatrix(ConfusionMatrix.builder().applyMutation(confusionMatrix).build()); } /** *

* A list of ColumnImportance structures containing column importance metrics, sorted in order of * descending importance. *

* * @param columnImportances * A list of ColumnImportance structures containing column importance metrics, sorted in * order of descending importance. * @return Returns a reference to this object so that method calls can be chained together. */ Builder columnImportances(Collection columnImportances); /** *

* A list of ColumnImportance structures containing column importance metrics, sorted in order of * descending importance. *

* * @param columnImportances * A list of ColumnImportance structures containing column importance metrics, sorted in * order of descending importance. * @return Returns a reference to this object so that method calls can be chained together. */ Builder columnImportances(ColumnImportance... columnImportances); /** *

* A list of ColumnImportance structures containing column importance metrics, sorted in order of * descending importance. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.glue.model.ColumnImportance.Builder} avoiding the need to create one * manually via {@link software.amazon.awssdk.services.glue.model.ColumnImportance#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.glue.model.ColumnImportance.Builder#build()} is called immediately and * its result is passed to {@link #columnImportances(List)}. * * @param columnImportances * a consumer that will call methods on * {@link software.amazon.awssdk.services.glue.model.ColumnImportance.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #columnImportances(java.util.Collection) */ Builder columnImportances(Consumer... columnImportances); } static final class BuilderImpl implements Builder { private Double areaUnderPRCurve; private Double precision; private Double recall; private Double f1; private ConfusionMatrix confusionMatrix; private List columnImportances = DefaultSdkAutoConstructList.getInstance(); private BuilderImpl() { } private BuilderImpl(FindMatchesMetrics model) { areaUnderPRCurve(model.areaUnderPRCurve); precision(model.precision); recall(model.recall); f1(model.f1); confusionMatrix(model.confusionMatrix); columnImportances(model.columnImportances); } public final Double getAreaUnderPRCurve() { return areaUnderPRCurve; } public final void setAreaUnderPRCurve(Double areaUnderPRCurve) { this.areaUnderPRCurve = areaUnderPRCurve; } @Override public final Builder areaUnderPRCurve(Double areaUnderPRCurve) { this.areaUnderPRCurve = areaUnderPRCurve; return this; } public final Double getPrecision() { return precision; } public final void setPrecision(Double precision) { this.precision = precision; } @Override public final Builder precision(Double precision) { this.precision = precision; return this; } public final Double getRecall() { return recall; } public final void setRecall(Double recall) { this.recall = recall; } @Override public final Builder recall(Double recall) { this.recall = recall; return this; } public final Double getF1() { return f1; } public final void setF1(Double f1) { this.f1 = f1; } @Override public final Builder f1(Double f1) { this.f1 = f1; return this; } public final ConfusionMatrix.Builder getConfusionMatrix() { return confusionMatrix != null ? confusionMatrix.toBuilder() : null; } public final void setConfusionMatrix(ConfusionMatrix.BuilderImpl confusionMatrix) { this.confusionMatrix = confusionMatrix != null ? confusionMatrix.build() : null; } @Override public final Builder confusionMatrix(ConfusionMatrix confusionMatrix) { this.confusionMatrix = confusionMatrix; return this; } public final List getColumnImportances() { List result = ColumnImportanceListCopier.copyToBuilder(this.columnImportances); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setColumnImportances(Collection columnImportances) { this.columnImportances = ColumnImportanceListCopier.copyFromBuilder(columnImportances); } @Override public final Builder columnImportances(Collection columnImportances) { this.columnImportances = ColumnImportanceListCopier.copy(columnImportances); return this; } @Override @SafeVarargs public final Builder columnImportances(ColumnImportance... columnImportances) { columnImportances(Arrays.asList(columnImportances)); return this; } @Override @SafeVarargs public final Builder columnImportances(Consumer... columnImportances) { columnImportances(Stream.of(columnImportances).map(c -> ColumnImportance.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } @Override public FindMatchesMetrics build() { return new FindMatchesMetrics(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy