diff --git a/src/Microsoft.ML.Transforms/NAReplaceTransform.cs b/src/Microsoft.ML.Transforms/NAReplaceTransform.cs
index 522237e303..52989472fc 100644
--- a/src/Microsoft.ML.Transforms/NAReplaceTransform.cs
+++ b/src/Microsoft.ML.Transforms/NAReplaceTransform.cs
@@ -43,6 +43,7 @@ public enum ReplacementKind
Mean,
Minimum,
Maximum,
+ SpecifiedValue,
[HideEnumValue]
Def = DefaultValue,
@@ -53,8 +54,6 @@ public enum ReplacementKind
[HideEnumValue]
Max = Maximum,
- [HideEnumValue]
- SpecifiedValue,
[HideEnumValue]
Val = SpecifiedValue,
[HideEnumValue]
diff --git a/src/Microsoft.ML/CSharpApi.cs b/src/Microsoft.ML/CSharpApi.cs
index e943e76bca..05edec3cd9 100644
--- a/src/Microsoft.ML/CSharpApi.cs
+++ b/src/Microsoft.ML/CSharpApi.cs
@@ -11058,14 +11058,10 @@ namespace Transforms
{
public enum NAHandleTransformReplacementKind
{
- Default = 0,
- Def = 0,
DefaultValue = 0,
Mean = 1,
Minimum = 2,
- Min = 2,
- Maximum = 3,
- Max = 3
+ Maximum = 3
}
@@ -11153,7 +11149,7 @@ public void AddColumn(string outputColumn, string inputColumn)
///
/// The replacement method to utilize
///
- public NAHandleTransformReplacementKind ReplaceWith { get; set; } = NAHandleTransformReplacementKind.Def;
+ public NAHandleTransformReplacementKind ReplaceWith { get; set; } = NAHandleTransformReplacementKind.DefaultValue;
///
/// Whether to impute values by slot
@@ -11527,17 +11523,11 @@ namespace Transforms
{
public enum NAReplaceTransformReplacementKind
{
- Default = 0,
DefaultValue = 0,
- Def = 0,
Mean = 1,
- Min = 2,
Minimum = 2,
- Max = 3,
Maximum = 3,
- SpecifiedValue = 4,
- Val = 4,
- Value = 4
+ SpecifiedValue = 4
}
@@ -11625,7 +11615,7 @@ public void AddColumn(string outputColumn, string inputColumn)
///
/// The replacement method to utilize
///
- public NAReplaceTransformReplacementKind ReplacementKind { get; set; } = NAReplaceTransformReplacementKind.Def;
+ public NAReplaceTransformReplacementKind ReplacementKind { get; set; } = NAReplaceTransformReplacementKind.DefaultValue;
///
/// Whether to impute values by slot
diff --git a/src/Microsoft.ML/Runtime/EntryPoints/JsonUtils/JsonManifestUtils.cs b/src/Microsoft.ML/Runtime/EntryPoints/JsonUtils/JsonManifestUtils.cs
index 7950975a22..fd76ad8565 100644
--- a/src/Microsoft.ML/Runtime/EntryPoints/JsonUtils/JsonManifestUtils.cs
+++ b/src/Microsoft.ML/Runtime/EntryPoints/JsonUtils/JsonManifestUtils.cs
@@ -344,7 +344,7 @@ private static JToken BuildTypeToken(IExceptionContext ectx, FieldInfo fieldInfo
case TlcModule.DataKind.Enum:
jo = new JObject();
jo[FieldNames.Kind] = typeEnum.ToString();
- var values = Enum.GetNames(type);
+ var values = Enum.GetNames(type).Where(n => type.GetField(n).GetCustomAttribute() == null);
jo[FieldNames.Values] = new JArray(values);
return jo;
case TlcModule.DataKind.Array:
diff --git a/src/Microsoft.ML/Runtime/Internal/Tools/CSharpApiGenerator.cs b/src/Microsoft.ML/Runtime/Internal/Tools/CSharpApiGenerator.cs
index ad714a4998..db7c1d490d 100644
--- a/src/Microsoft.ML/Runtime/Internal/Tools/CSharpApiGenerator.cs
+++ b/src/Microsoft.ML/Runtime/Internal/Tools/CSharpApiGenerator.cs
@@ -6,6 +6,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using System.Reflection;
using Microsoft.ML.Runtime;
using Microsoft.ML.Runtime.CommandLine;
using Microsoft.ML.Runtime.Data;
@@ -156,6 +157,8 @@ private void GenerateEnums(IndentingTextWriter writer, Type inputType, string cu
for (int i = 0; i < names.Length; i++)
{
var name = names[i];
+ if (type.GetField(name).GetCustomAttribute() != null)
+ continue;
var value = values.GetValue(i);
writer.WriteLine(prefix);
if (enumType == typeof(int))
diff --git a/src/Microsoft.ML/Runtime/Internal/Tools/CSharpGeneratorUtils.cs b/src/Microsoft.ML/Runtime/Internal/Tools/CSharpGeneratorUtils.cs
index fc9fabb758..cca73a21f9 100644
--- a/src/Microsoft.ML/Runtime/Internal/Tools/CSharpGeneratorUtils.cs
+++ b/src/Microsoft.ML/Runtime/Internal/Tools/CSharpGeneratorUtils.cs
@@ -6,6 +6,7 @@
using System.CodeDom;
using System.Collections.Generic;
using System.Linq;
+using System.Reflection;
using Microsoft.CSharp;
using Microsoft.ML.Runtime.CommandLine;
using Microsoft.ML.Runtime.EntryPoints;
@@ -279,10 +280,22 @@ public static string GetValue(ModuleCatalog catalog, Type fieldType, object fiel
case TlcModule.DataKind.Bool:
return (bool)fieldValue ? "true" : "false";
case TlcModule.DataKind.Enum:
+ string enumAsString = fieldValue.ToString();
+ if (fieldType.GetField(enumAsString).GetCustomAttribute() != null)
+ {
+ // The default value for the enum has the hiding attribute on it. We will search for
+ // alternate names. Regrettably I see no way beyond a manual scan.
+
+ string unhiddenName = Enum.GetNames(fieldType).Zip(Enum.GetValues(fieldType).Cast