Exemple #1
0
        internal static AutoMLVertical DeserializeAutoMLVertical(JsonElement element)
        {
            if (element.TryGetProperty("taskType", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "Classification": return(Classification.DeserializeClassification(element));

                case "Forecasting": return(Forecasting.DeserializeForecasting(element));

                case "ImageClassification": return(ImageClassification.DeserializeImageClassification(element));

                case "ImageClassificationMultilabel": return(ImageClassificationMultilabel.DeserializeImageClassificationMultilabel(element));

                case "ImageInstanceSegmentation": return(ImageInstanceSegmentation.DeserializeImageInstanceSegmentation(element));

                case "ImageObjectDetection": return(ImageObjectDetection.DeserializeImageObjectDetection(element));

                case "Regression": return(Regression.DeserializeRegression(element));

                case "TextClassification": return(TextClassification.DeserializeTextClassification(element));

                case "TextClassificationMultilabel": return(TextClassificationMultilabel.DeserializeTextClassificationMultilabel(element));

                case "TextNER": return(TextNer.DeserializeTextNer(element));
                }
            }
            Optional <LogVerbosity> logVerbosity = default;
            TaskType taskType = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("logVerbosity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    logVerbosity = new LogVerbosity(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("taskType"))
                {
                    taskType = new TaskType(property.Value.GetString());
                    continue;
                }
            }
            return(new AutoMLVertical(Optional.ToNullable(logVerbosity), taskType));
        }
Exemple #2
0
        internal static ImageObjectDetection DeserializeImageObjectDetection(JsonElement element)
        {
            Optional <ObjectDetectionPrimaryMetrics>     primaryMetric = default;
            Optional <ImageModelSettingsObjectDetection> modelSettings = default;
            Optional <IList <ImageModelDistributionSettingsObjectDetection> > searchSpace = default;
            ImageVerticalDataSettings     dataSettings  = default;
            ImageLimitSettings            limitSettings = default;
            Optional <ImageSweepSettings> sweepSettings = default;
            Optional <LogVerbosity>       logVerbosity  = default;
            TaskType taskType = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("primaryMetric"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    primaryMetric = new ObjectDetectionPrimaryMetrics(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("modelSettings"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        modelSettings = null;
                        continue;
                    }
                    modelSettings = ImageModelSettingsObjectDetection.DeserializeImageModelSettingsObjectDetection(property.Value);
                    continue;
                }
                if (property.NameEquals("searchSpace"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        searchSpace = null;
                        continue;
                    }
                    List <ImageModelDistributionSettingsObjectDetection> array = new List <ImageModelDistributionSettingsObjectDetection>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(ImageModelDistributionSettingsObjectDetection.DeserializeImageModelDistributionSettingsObjectDetection(item));
                    }
                    searchSpace = array;
                    continue;
                }
                if (property.NameEquals("dataSettings"))
                {
                    dataSettings = ImageVerticalDataSettings.DeserializeImageVerticalDataSettings(property.Value);
                    continue;
                }
                if (property.NameEquals("limitSettings"))
                {
                    limitSettings = ImageLimitSettings.DeserializeImageLimitSettings(property.Value);
                    continue;
                }
                if (property.NameEquals("sweepSettings"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        sweepSettings = null;
                        continue;
                    }
                    sweepSettings = ImageSweepSettings.DeserializeImageSweepSettings(property.Value);
                    continue;
                }
                if (property.NameEquals("logVerbosity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    logVerbosity = new LogVerbosity(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("taskType"))
                {
                    taskType = new TaskType(property.Value.GetString());
                    continue;
                }
            }
            return(new ImageObjectDetection(Optional.ToNullable(logVerbosity), taskType, Optional.ToNullable(primaryMetric), modelSettings.Value, Optional.ToList(searchSpace), dataSettings, limitSettings, sweepSettings.Value));
        }
Exemple #3
0
        internal static Classification DeserializeClassification(JsonElement element)
        {
            Optional <IList <ClassificationModels> >      allowedModels         = default;
            Optional <IList <ClassificationModels> >      blockedModels         = default;
            Optional <ClassificationPrimaryMetrics>       primaryMetric         = default;
            Optional <TableVerticalDataSettings>          dataSettings          = default;
            Optional <TableVerticalFeaturizationSettings> featurizationSettings = default;
            Optional <TableVerticalLimitSettings>         limitSettings         = default;
            Optional <TrainingSettings> trainingSettings = default;
            Optional <LogVerbosity>     logVerbosity     = default;
            TaskType taskType = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("allowedModels"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        allowedModels = null;
                        continue;
                    }
                    List <ClassificationModels> array = new List <ClassificationModels>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(new ClassificationModels(item.GetString()));
                    }
                    allowedModels = array;
                    continue;
                }
                if (property.NameEquals("blockedModels"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        blockedModels = null;
                        continue;
                    }
                    List <ClassificationModels> array = new List <ClassificationModels>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(new ClassificationModels(item.GetString()));
                    }
                    blockedModels = array;
                    continue;
                }
                if (property.NameEquals("primaryMetric"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    primaryMetric = new ClassificationPrimaryMetrics(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("dataSettings"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        dataSettings = null;
                        continue;
                    }
                    dataSettings = TableVerticalDataSettings.DeserializeTableVerticalDataSettings(property.Value);
                    continue;
                }
                if (property.NameEquals("featurizationSettings"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        featurizationSettings = null;
                        continue;
                    }
                    featurizationSettings = TableVerticalFeaturizationSettings.DeserializeTableVerticalFeaturizationSettings(property.Value);
                    continue;
                }
                if (property.NameEquals("limitSettings"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        limitSettings = null;
                        continue;
                    }
                    limitSettings = TableVerticalLimitSettings.DeserializeTableVerticalLimitSettings(property.Value);
                    continue;
                }
                if (property.NameEquals("trainingSettings"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        trainingSettings = null;
                        continue;
                    }
                    trainingSettings = TrainingSettings.DeserializeTrainingSettings(property.Value);
                    continue;
                }
                if (property.NameEquals("logVerbosity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    logVerbosity = new LogVerbosity(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("taskType"))
                {
                    taskType = new TaskType(property.Value.GetString());
                    continue;
                }
            }
            return(new Classification(Optional.ToNullable(logVerbosity), taskType, Optional.ToList(allowedModels), Optional.ToList(blockedModels), Optional.ToNullable(primaryMetric), dataSettings.Value, featurizationSettings.Value, limitSettings.Value, trainingSettings.Value));
        }
Exemple #4
0
        internal static TextClassificationMultilabel DeserializeTextClassificationMultilabel(JsonElement element)
        {
            Optional <ClassificationMultilabelPrimaryMetrics> primaryMetric   = default;
            Optional <NlpVerticalDataSettings>          dataSettings          = default;
            Optional <NlpVerticalFeaturizationSettings> featurizationSettings = default;
            Optional <NlpVerticalLimitSettings>         limitSettings         = default;
            Optional <LogVerbosity> logVerbosity = default;
            TaskType taskType = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("primaryMetric"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    primaryMetric = new ClassificationMultilabelPrimaryMetrics(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("dataSettings"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        dataSettings = null;
                        continue;
                    }
                    dataSettings = NlpVerticalDataSettings.DeserializeNlpVerticalDataSettings(property.Value);
                    continue;
                }
                if (property.NameEquals("featurizationSettings"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        featurizationSettings = null;
                        continue;
                    }
                    featurizationSettings = NlpVerticalFeaturizationSettings.DeserializeNlpVerticalFeaturizationSettings(property.Value);
                    continue;
                }
                if (property.NameEquals("limitSettings"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        limitSettings = null;
                        continue;
                    }
                    limitSettings = NlpVerticalLimitSettings.DeserializeNlpVerticalLimitSettings(property.Value);
                    continue;
                }
                if (property.NameEquals("logVerbosity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    logVerbosity = new LogVerbosity(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("taskType"))
                {
                    taskType = new TaskType(property.Value.GetString());
                    continue;
                }
            }
            return(new TextClassificationMultilabel(Optional.ToNullable(logVerbosity), taskType, Optional.ToNullable(primaryMetric), dataSettings.Value, featurizationSettings.Value, limitSettings.Value));
        }