Skip to content

Add TargetType to Type_convert #6785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions src/Microsoft.ML.AutoML/CodeGen/search-space-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,26 @@
"BertArchitecture.Roberta"
]
},
"dataKind": {
"type": "string",
"enum": [
"DataKind.Int16",
"DataKind.SByte",
"DataKind.Byte",
"DataKind.UInt16",
"DataKind.Int32",
"DataKind.UInt32",
"DataKind.Int64",
"DataKind.UInt64",
"DataKind.Single",
"DataKind.Double",
"DataKind.String",
"DataKind.Boolean",
"DataKind.TimeSpan",
"DataKind.DateTime",
"DataKind.DateTimeOffset"
]
},
"bertArchitectureArray": {
"type": "array",
"items": {
Expand Down Expand Up @@ -217,7 +237,8 @@
"TrainingAnswerColumnName",
"AnswerIndexStartColumnName",
"predictedAnswerColumnName",
"TopKAnswers"
"TopKAnswers",
"TargetType"
]
},
"option_type": {
Expand All @@ -235,7 +256,8 @@
"anchor",
"dnnModelFactory",
"bertArchitecture",
"imageClassificationArchType"
"imageClassificationArchType",
"dataKind"
]
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
{
"name": "InputColumnNames",
"type": "strings"
},
{
"name": "TargetType",
"type": "dataKind",
"default": "DataKind.Single"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal partial class ConvertType
public override IEstimator<ITransformer> BuildFromOption(MLContext context, ConvertTypeOption param)
{
var inputOutputPairs = AutoMlUtils.CreateInputOutputColumnPairsFromStrings(param.InputColumnNames, param.OutputColumnNames);
return context.Transforms.Conversion.ConvertType(inputOutputPairs);
return context.Transforms.Conversion.ConvertType(inputOutputPairs, param.TargetType);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
],
"InputColumnNames": [
"BooleanFeatures"
]
],
"TargetType": "Single"
}
},
"e2": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
],
"InputColumnNames": [
"dummy for Children"
]
],
"TargetType": "Single"
}
},
"e2": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public void Execute(GeneratorExecutionContext context)
"dnnModelFactory" => "string",
"bertArchitecture" => "BertArchitecture",
"imageClassificationArchType" => "Microsoft.ML.Vision.ImageClassificationTrainer.Architecture",
"dataKind" => "Microsoft.ML.Data.DataKind",
_ => throw new ArgumentException("unknown type"),
};

Expand All @@ -74,6 +75,7 @@ public void Execute(GeneratorExecutionContext context)
(_, "ColorsOrder") => defaultToken.GetValue<string>(),
(_, "BertArchitecture") => defaultToken.GetValue<string>(),
(_, "Microsoft.ML.Vision.ImageClassificationTrainer.Architecture") => defaultToken.GetValue<string>(),
(_, "Microsoft.ML.Data.DataKind") => defaultToken.GetValue<string>(),
(_, _) => throw new ArgumentException("unknown"),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public virtual string TransformText()
using Anchor = Microsoft.ML.Transforms.Image.ImageResizingEstimator.Anchor;
using BertArchitecture = Microsoft.ML.TorchSharp.NasBert.BertArchitecture;
using static Microsoft.ML.Vision.ImageClassificationTrainer.Architecture;
using DataKind = Microsoft.ML.Data.DataKind;
#nullable enable

namespace ");
Expand Down Expand Up @@ -92,7 +93,7 @@ internal class SearchSpaceBase
/// <summary>
/// The string builder that generation-time code is using to assemble generated output
/// </summary>
protected System.Text.StringBuilder GenerationEnvironment
public System.Text.StringBuilder GenerationEnvironment
{
get
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ using ResizingKind = Microsoft.ML.Transforms.Image.ImageResizingEstimator.Resizi
using Anchor = Microsoft.ML.Transforms.Image.ImageResizingEstimator.Anchor;
using BertArchitecture = Microsoft.ML.TorchSharp.NasBert.BertArchitecture;
using static Microsoft.ML.Vision.ImageClassificationTrainer.Architecture;
using DataKind = Microsoft.ML.Data.DataKind;
#nullable enable

namespace <#=NameSpace#>
Expand Down