software.amazon.awssdk.services.sagemaker.model.ClarifyShapConfig Maven / Gradle / Ivy
Show all versions of sagemaker Show documentation
/*
* 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.sagemaker.model;
import java.io.Serializable;
import java.util.Arrays;
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 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.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* The configuration for SHAP analysis using SageMaker Clarify Explainer.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ClarifyShapConfig implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField SHAP_BASELINE_CONFIG_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("ShapBaselineConfig")
.getter(getter(ClarifyShapConfig::shapBaselineConfig)).setter(setter(Builder::shapBaselineConfig))
.constructor(ClarifyShapBaselineConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ShapBaselineConfig").build())
.build();
private static final SdkField NUMBER_OF_SAMPLES_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("NumberOfSamples").getter(getter(ClarifyShapConfig::numberOfSamples))
.setter(setter(Builder::numberOfSamples))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NumberOfSamples").build()).build();
private static final SdkField USE_LOGIT_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("UseLogit").getter(getter(ClarifyShapConfig::useLogit)).setter(setter(Builder::useLogit))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("UseLogit").build()).build();
private static final SdkField SEED_FIELD = SdkField. builder(MarshallingType.INTEGER).memberName("Seed")
.getter(getter(ClarifyShapConfig::seed)).setter(setter(Builder::seed))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Seed").build()).build();
private static final SdkField TEXT_CONFIG_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("TextConfig")
.getter(getter(ClarifyShapConfig::textConfig)).setter(setter(Builder::textConfig))
.constructor(ClarifyTextConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TextConfig").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(SHAP_BASELINE_CONFIG_FIELD,
NUMBER_OF_SAMPLES_FIELD, USE_LOGIT_FIELD, SEED_FIELD, TEXT_CONFIG_FIELD));
private static final long serialVersionUID = 1L;
private final ClarifyShapBaselineConfig shapBaselineConfig;
private final Integer numberOfSamples;
private final Boolean useLogit;
private final Integer seed;
private final ClarifyTextConfig textConfig;
private ClarifyShapConfig(BuilderImpl builder) {
this.shapBaselineConfig = builder.shapBaselineConfig;
this.numberOfSamples = builder.numberOfSamples;
this.useLogit = builder.useLogit;
this.seed = builder.seed;
this.textConfig = builder.textConfig;
}
/**
*
* The configuration for the SHAP baseline of the Kernal SHAP algorithm.
*
*
* @return The configuration for the SHAP baseline of the Kernal SHAP algorithm.
*/
public final ClarifyShapBaselineConfig shapBaselineConfig() {
return shapBaselineConfig;
}
/**
*
* The number of samples to be used for analysis by the Kernal SHAP algorithm.
*
*
*
* The number of samples determines the size of the synthetic dataset, which has an impact on latency of
* explainability requests. For more information, see the Synthetic data of Configure and create an endpoint.
*
*
*
* @return The number of samples to be used for analysis by the Kernal SHAP algorithm.
*
* The number of samples determines the size of the synthetic dataset, which has an impact on latency of
* explainability requests. For more information, see the Synthetic data of Configure and create an endpoint.
*
*/
public final Integer numberOfSamples() {
return numberOfSamples;
}
/**
*
* A Boolean toggle to indicate if you want to use the logit function (true) or log-odds units (false) for model
* predictions. Defaults to false.
*
*
* @return A Boolean toggle to indicate if you want to use the logit function (true) or log-odds units (false) for
* model predictions. Defaults to false.
*/
public final Boolean useLogit() {
return useLogit;
}
/**
*
* The starting value used to initialize the random number generator in the explainer. Provide a value for this
* parameter to obtain a deterministic SHAP result.
*
*
* @return The starting value used to initialize the random number generator in the explainer. Provide a value for
* this parameter to obtain a deterministic SHAP result.
*/
public final Integer seed() {
return seed;
}
/**
*
* A parameter that indicates if text features are treated as text and explanations are provided for individual
* units of text. Required for natural language processing (NLP) explainability only.
*
*
* @return A parameter that indicates if text features are treated as text and explanations are provided for
* individual units of text. Required for natural language processing (NLP) explainability only.
*/
public final ClarifyTextConfig textConfig() {
return textConfig;
}
@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(shapBaselineConfig());
hashCode = 31 * hashCode + Objects.hashCode(numberOfSamples());
hashCode = 31 * hashCode + Objects.hashCode(useLogit());
hashCode = 31 * hashCode + Objects.hashCode(seed());
hashCode = 31 * hashCode + Objects.hashCode(textConfig());
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 ClarifyShapConfig)) {
return false;
}
ClarifyShapConfig other = (ClarifyShapConfig) obj;
return Objects.equals(shapBaselineConfig(), other.shapBaselineConfig())
&& Objects.equals(numberOfSamples(), other.numberOfSamples()) && Objects.equals(useLogit(), other.useLogit())
&& Objects.equals(seed(), other.seed()) && Objects.equals(textConfig(), other.textConfig());
}
/**
* 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("ClarifyShapConfig").add("ShapBaselineConfig", shapBaselineConfig())
.add("NumberOfSamples", numberOfSamples()).add("UseLogit", useLogit()).add("Seed", seed())
.add("TextConfig", textConfig()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ShapBaselineConfig":
return Optional.ofNullable(clazz.cast(shapBaselineConfig()));
case "NumberOfSamples":
return Optional.ofNullable(clazz.cast(numberOfSamples()));
case "UseLogit":
return Optional.ofNullable(clazz.cast(useLogit()));
case "Seed":
return Optional.ofNullable(clazz.cast(seed()));
case "TextConfig":
return Optional.ofNullable(clazz.cast(textConfig()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function