software.amazon.awssdk.services.sagemaker.model.TimeSeriesForecastingJobConfig 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.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 collection of settings used by an AutoML job V2 for the time-series forecasting problem type.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class TimeSeriesForecastingJobConfig implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField FEATURE_SPECIFICATION_S3_URI_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("FeatureSpecificationS3Uri").getter(getter(TimeSeriesForecastingJobConfig::featureSpecificationS3Uri))
.setter(setter(Builder::featureSpecificationS3Uri))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FeatureSpecificationS3Uri").build())
.build();
private static final SdkField COMPLETION_CRITERIA_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("CompletionCriteria")
.getter(getter(TimeSeriesForecastingJobConfig::completionCriteria)).setter(setter(Builder::completionCriteria))
.constructor(AutoMLJobCompletionCriteria::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CompletionCriteria").build())
.build();
private static final SdkField FORECAST_FREQUENCY_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("ForecastFrequency").getter(getter(TimeSeriesForecastingJobConfig::forecastFrequency))
.setter(setter(Builder::forecastFrequency))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ForecastFrequency").build()).build();
private static final SdkField FORECAST_HORIZON_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("ForecastHorizon").getter(getter(TimeSeriesForecastingJobConfig::forecastHorizon))
.setter(setter(Builder::forecastHorizon))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ForecastHorizon").build()).build();
private static final SdkField> FORECAST_QUANTILES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("ForecastQuantiles")
.getter(getter(TimeSeriesForecastingJobConfig::forecastQuantiles))
.setter(setter(Builder::forecastQuantiles))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ForecastQuantiles").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField TRANSFORMATIONS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("Transformations")
.getter(getter(TimeSeriesForecastingJobConfig::transformations)).setter(setter(Builder::transformations))
.constructor(TimeSeriesTransformations::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Transformations").build()).build();
private static final SdkField TIME_SERIES_CONFIG_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("TimeSeriesConfig")
.getter(getter(TimeSeriesForecastingJobConfig::timeSeriesConfig)).setter(setter(Builder::timeSeriesConfig))
.constructor(TimeSeriesConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TimeSeriesConfig").build()).build();
private static final SdkField> HOLIDAY_CONFIG_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("HolidayConfig")
.getter(getter(TimeSeriesForecastingJobConfig::holidayConfig))
.setter(setter(Builder::holidayConfig))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HolidayConfig").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(HolidayConfigAttributes::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField CANDIDATE_GENERATION_CONFIG_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("CandidateGenerationConfig")
.getter(getter(TimeSeriesForecastingJobConfig::candidateGenerationConfig))
.setter(setter(Builder::candidateGenerationConfig)).constructor(CandidateGenerationConfig::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CandidateGenerationConfig").build())
.build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(
FEATURE_SPECIFICATION_S3_URI_FIELD, COMPLETION_CRITERIA_FIELD, FORECAST_FREQUENCY_FIELD, FORECAST_HORIZON_FIELD,
FORECAST_QUANTILES_FIELD, TRANSFORMATIONS_FIELD, TIME_SERIES_CONFIG_FIELD, HOLIDAY_CONFIG_FIELD,
CANDIDATE_GENERATION_CONFIG_FIELD));
private static final long serialVersionUID = 1L;
private final String featureSpecificationS3Uri;
private final AutoMLJobCompletionCriteria completionCriteria;
private final String forecastFrequency;
private final Integer forecastHorizon;
private final List forecastQuantiles;
private final TimeSeriesTransformations transformations;
private final TimeSeriesConfig timeSeriesConfig;
private final List holidayConfig;
private final CandidateGenerationConfig candidateGenerationConfig;
private TimeSeriesForecastingJobConfig(BuilderImpl builder) {
this.featureSpecificationS3Uri = builder.featureSpecificationS3Uri;
this.completionCriteria = builder.completionCriteria;
this.forecastFrequency = builder.forecastFrequency;
this.forecastHorizon = builder.forecastHorizon;
this.forecastQuantiles = builder.forecastQuantiles;
this.transformations = builder.transformations;
this.timeSeriesConfig = builder.timeSeriesConfig;
this.holidayConfig = builder.holidayConfig;
this.candidateGenerationConfig = builder.candidateGenerationConfig;
}
/**
*
* A URL to the Amazon S3 data source containing additional selected features that complement the target, itemID,
* timestamp, and grouped columns set in TimeSeriesConfig
. When not provided, the AutoML job V2
* includes all the columns from the original dataset that are not already declared in TimeSeriesConfig
* . If provided, the AutoML job V2 only considers these additional columns as a complement to the ones declared in
* TimeSeriesConfig
.
*
*
* You can input FeatureAttributeNames
(optional) in JSON format as shown below:
*
*
* { "FeatureAttributeNames":["col1", "col2", ...] }
.
*
*
* You can also specify the data type of the feature (optional) in the format shown below:
*
*
* { "FeatureDataTypes":{"col1":"numeric", "col2":"categorical" ... } }
*
*
* Autopilot supports the following data types: numeric
, categorical
, text
,
* and datetime
.
*
*
*
* These column keys must not include any column set in TimeSeriesConfig
.
*
*
*
* @return A URL to the Amazon S3 data source containing additional selected features that complement the target,
* itemID, timestamp, and grouped columns set in TimeSeriesConfig
. When not provided, the
* AutoML job V2 includes all the columns from the original dataset that are not already declared in
* TimeSeriesConfig
. If provided, the AutoML job V2 only considers these additional columns as
* a complement to the ones declared in TimeSeriesConfig
.
*
* You can input FeatureAttributeNames
(optional) in JSON format as shown below:
*
*
* { "FeatureAttributeNames":["col1", "col2", ...] }
.
*
*
* You can also specify the data type of the feature (optional) in the format shown below:
*
*
* { "FeatureDataTypes":{"col1":"numeric", "col2":"categorical" ... } }
*
*
* Autopilot supports the following data types: numeric
, categorical
,
* text
, and datetime
.
*
*
*
* These column keys must not include any column set in TimeSeriesConfig
.
*
*/
public final String featureSpecificationS3Uri() {
return featureSpecificationS3Uri;
}
/**
* Returns the value of the CompletionCriteria property for this object.
*
* @return The value of the CompletionCriteria property for this object.
*/
public final AutoMLJobCompletionCriteria completionCriteria() {
return completionCriteria;
}
/**
*
* The frequency of predictions in a forecast.
*
*
* Valid intervals are an integer followed by Y (Year), M (Month), W (Week), D (Day), H (Hour), and min (Minute).
* For example, 1D
indicates every day and 15min
indicates every 15 minutes. The value of
* a frequency must not overlap with the next larger frequency. For example, you must use a frequency of
* 1H
instead of 60min
.
*
*
* The valid values for each frequency are the following:
*
*
* -
*
* Minute - 1-59
*
*
* -
*
* Hour - 1-23
*
*
* -
*
* Day - 1-6
*
*
* -
*
* Week - 1-4
*
*
* -
*
* Month - 1-11
*
*
* -
*
* Year - 1
*
*
*
*
* @return The frequency of predictions in a forecast.
*
* Valid intervals are an integer followed by Y (Year), M (Month), W (Week), D (Day), H (Hour), and min
* (Minute). For example, 1D
indicates every day and 15min
indicates every 15
* minutes. The value of a frequency must not overlap with the next larger frequency. For example, you must
* use a frequency of 1H
instead of 60min
.
*
*
* The valid values for each frequency are the following:
*
*
* -
*
* Minute - 1-59
*
*
* -
*
* Hour - 1-23
*
*
* -
*
* Day - 1-6
*
*
* -
*
* Week - 1-4
*
*
* -
*
* Month - 1-11
*
*
* -
*
* Year - 1
*
*
*/
public final String forecastFrequency() {
return forecastFrequency;
}
/**
*
* The number of time-steps that the model predicts. The forecast horizon is also called the prediction length. The
* maximum forecast horizon is the lesser of 500 time-steps or 1/4 of the time-steps in the dataset.
*
*
* @return The number of time-steps that the model predicts. The forecast horizon is also called the prediction
* length. The maximum forecast horizon is the lesser of 500 time-steps or 1/4 of the time-steps in the
* dataset.
*/
public final Integer forecastHorizon() {
return forecastHorizon;
}
/**
* For responses, this returns true if the service returned a value for the ForecastQuantiles 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 hasForecastQuantiles() {
return forecastQuantiles != null && !(forecastQuantiles instanceof SdkAutoConstructList);
}
/**
*
* The quantiles used to train the model for forecasts at a specified quantile. You can specify quantiles from
* 0.01
(p1) to 0.99
(p99), by increments of 0.01 or higher. Up to five forecast quantiles
* can be specified. When ForecastQuantiles
is not provided, the AutoML job uses the quantiles p10,
* p50, and p90 as default.
*
*
* 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 #hasForecastQuantiles} method.
*
*
* @return The quantiles used to train the model for forecasts at a specified quantile. You can specify quantiles
* from 0.01
(p1) to 0.99
(p99), by increments of 0.01 or higher. Up to five
* forecast quantiles can be specified. When ForecastQuantiles
is not provided, the AutoML job
* uses the quantiles p10, p50, and p90 as default.
*/
public final List forecastQuantiles() {
return forecastQuantiles;
}
/**
*
* The transformations modifying specific attributes of the time-series, such as filling strategies for missing
* values.
*
*
* @return The transformations modifying specific attributes of the time-series, such as filling strategies for
* missing values.
*/
public final TimeSeriesTransformations transformations() {
return transformations;
}
/**
*
* The collection of components that defines the time-series.
*
*
* @return The collection of components that defines the time-series.
*/
public final TimeSeriesConfig timeSeriesConfig() {
return timeSeriesConfig;
}
/**
* For responses, this returns true if the service returned a value for the HolidayConfig 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 hasHolidayConfig() {
return holidayConfig != null && !(holidayConfig instanceof SdkAutoConstructList);
}
/**
*
* The collection of holiday featurization attributes used to incorporate national holiday information into your
* forecasting model.
*
*
* 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 #hasHolidayConfig} method.
*
*
* @return The collection of holiday featurization attributes used to incorporate national holiday information into
* your forecasting model.
*/
public final List holidayConfig() {
return holidayConfig;
}
/**
* Returns the value of the CandidateGenerationConfig property for this object.
*
* @return The value of the CandidateGenerationConfig property for this object.
*/
public final CandidateGenerationConfig candidateGenerationConfig() {
return candidateGenerationConfig;
}
@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(featureSpecificationS3Uri());
hashCode = 31 * hashCode + Objects.hashCode(completionCriteria());
hashCode = 31 * hashCode + Objects.hashCode(forecastFrequency());
hashCode = 31 * hashCode + Objects.hashCode(forecastHorizon());
hashCode = 31 * hashCode + Objects.hashCode(hasForecastQuantiles() ? forecastQuantiles() : null);
hashCode = 31 * hashCode + Objects.hashCode(transformations());
hashCode = 31 * hashCode + Objects.hashCode(timeSeriesConfig());
hashCode = 31 * hashCode + Objects.hashCode(hasHolidayConfig() ? holidayConfig() : null);
hashCode = 31 * hashCode + Objects.hashCode(candidateGenerationConfig());
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 TimeSeriesForecastingJobConfig)) {
return false;
}
TimeSeriesForecastingJobConfig other = (TimeSeriesForecastingJobConfig) obj;
return Objects.equals(featureSpecificationS3Uri(), other.featureSpecificationS3Uri())
&& Objects.equals(completionCriteria(), other.completionCriteria())
&& Objects.equals(forecastFrequency(), other.forecastFrequency())
&& Objects.equals(forecastHorizon(), other.forecastHorizon())
&& hasForecastQuantiles() == other.hasForecastQuantiles()
&& Objects.equals(forecastQuantiles(), other.forecastQuantiles())
&& Objects.equals(transformations(), other.transformations())
&& Objects.equals(timeSeriesConfig(), other.timeSeriesConfig()) && hasHolidayConfig() == other.hasHolidayConfig()
&& Objects.equals(holidayConfig(), other.holidayConfig())
&& Objects.equals(candidateGenerationConfig(), other.candidateGenerationConfig());
}
/**
* 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("TimeSeriesForecastingJobConfig").add("FeatureSpecificationS3Uri", featureSpecificationS3Uri())
.add("CompletionCriteria", completionCriteria()).add("ForecastFrequency", forecastFrequency())
.add("ForecastHorizon", forecastHorizon())
.add("ForecastQuantiles", hasForecastQuantiles() ? forecastQuantiles() : null)
.add("Transformations", transformations()).add("TimeSeriesConfig", timeSeriesConfig())
.add("HolidayConfig", hasHolidayConfig() ? holidayConfig() : null)
.add("CandidateGenerationConfig", candidateGenerationConfig()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "FeatureSpecificationS3Uri":
return Optional.ofNullable(clazz.cast(featureSpecificationS3Uri()));
case "CompletionCriteria":
return Optional.ofNullable(clazz.cast(completionCriteria()));
case "ForecastFrequency":
return Optional.ofNullable(clazz.cast(forecastFrequency()));
case "ForecastHorizon":
return Optional.ofNullable(clazz.cast(forecastHorizon()));
case "ForecastQuantiles":
return Optional.ofNullable(clazz.cast(forecastQuantiles()));
case "Transformations":
return Optional.ofNullable(clazz.cast(transformations()));
case "TimeSeriesConfig":
return Optional.ofNullable(clazz.cast(timeSeriesConfig()));
case "HolidayConfig":
return Optional.ofNullable(clazz.cast(holidayConfig()));
case "CandidateGenerationConfig":
return Optional.ofNullable(clazz.cast(candidateGenerationConfig()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function