Ejemplo n.º 1
0
 internal ForecastingSettings(string countryOrRegionForHolidays, int?cvStepSize, FeatureLags?featureLags, ForecastHorizon forecastHorizon, string frequency, Seasonality seasonality, ShortSeriesHandlingConfiguration?shortSeriesHandlingConfig, TargetAggregationFunction?targetAggregateFunction, TargetLags targetLags, TargetRollingWindowSize targetRollingWindowSize, string timeColumnName, IList <string> timeSeriesIdColumnNames, UseStl?useStl)
 {
     CountryOrRegionForHolidays = countryOrRegionForHolidays;
     CvStepSize                = cvStepSize;
     FeatureLags               = featureLags;
     ForecastHorizon           = forecastHorizon;
     Frequency                 = frequency;
     Seasonality               = seasonality;
     ShortSeriesHandlingConfig = shortSeriesHandlingConfig;
     TargetAggregateFunction   = targetAggregateFunction;
     TargetLags                = targetLags;
     TargetRollingWindowSize   = targetRollingWindowSize;
     TimeColumnName            = timeColumnName;
     TimeSeriesIdColumnNames   = timeSeriesIdColumnNames;
     UseStl = useStl;
 }
Ejemplo n.º 2
0
        internal static ForecastingSettings DeserializeForecastingSettings(JsonElement element)
        {
            Optional <string>          countryOrRegionForHolidays = default;
            Optional <int>             cvStepSize      = default;
            Optional <FeatureLags>     featureLags     = default;
            Optional <ForecastHorizon> forecastHorizon = default;
            Optional <string>          frequency       = default;
            Optional <Seasonality>     seasonality     = default;
            Optional <ShortSeriesHandlingConfiguration> shortSeriesHandlingConfig = default;
            Optional <TargetAggregationFunction>        targetAggregateFunction   = default;
            Optional <TargetLags> targetLags = default;
            Optional <TargetRollingWindowSize> targetRollingWindowSize = default;
            Optional <string>          timeColumnName          = default;
            Optional <IList <string> > timeSeriesIdColumnNames = default;
            Optional <UseStl>          useStl = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("countryOrRegionForHolidays"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        countryOrRegionForHolidays = null;
                        continue;
                    }
                    countryOrRegionForHolidays = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("cvStepSize"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    cvStepSize = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("featureLags"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    featureLags = new FeatureLags(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("forecastHorizon"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        forecastHorizon = null;
                        continue;
                    }
                    forecastHorizon = ForecastHorizon.DeserializeForecastHorizon(property.Value);
                    continue;
                }
                if (property.NameEquals("frequency"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        frequency = null;
                        continue;
                    }
                    frequency = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("seasonality"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        seasonality = null;
                        continue;
                    }
                    seasonality = Seasonality.DeserializeSeasonality(property.Value);
                    continue;
                }
                if (property.NameEquals("shortSeriesHandlingConfig"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    shortSeriesHandlingConfig = new ShortSeriesHandlingConfiguration(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("targetAggregateFunction"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    targetAggregateFunction = new TargetAggregationFunction(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("targetLags"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        targetLags = null;
                        continue;
                    }
                    targetLags = TargetLags.DeserializeTargetLags(property.Value);
                    continue;
                }
                if (property.NameEquals("targetRollingWindowSize"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        targetRollingWindowSize = null;
                        continue;
                    }
                    targetRollingWindowSize = TargetRollingWindowSize.DeserializeTargetRollingWindowSize(property.Value);
                    continue;
                }
                if (property.NameEquals("timeColumnName"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        timeColumnName = null;
                        continue;
                    }
                    timeColumnName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("timeSeriesIdColumnNames"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        timeSeriesIdColumnNames = null;
                        continue;
                    }
                    List <string> array = new List <string>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetString());
                    }
                    timeSeriesIdColumnNames = array;
                    continue;
                }
                if (property.NameEquals("useStl"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    useStl = new UseStl(property.Value.GetString());
                    continue;
                }
            }
            return(new ForecastingSettings(countryOrRegionForHolidays.Value, Optional.ToNullable(cvStepSize), Optional.ToNullable(featureLags), forecastHorizon.Value, frequency.Value, seasonality.Value, Optional.ToNullable(shortSeriesHandlingConfig), Optional.ToNullable(targetAggregateFunction), targetLags.Value, targetRollingWindowSize.Value, timeColumnName.Value, Optional.ToList(timeSeriesIdColumnNames), Optional.ToNullable(useStl)));
        }