Skip to content

Commit 9e0a4ba

Browse files
authored
Fix bug #435. (#437)
* Fix bug #435. * Fix unit tests. * Fix bug in generating new key column.
1 parent fb8cf0b commit 9e0a4ba

File tree

5 files changed

+604
-604
lines changed

5 files changed

+604
-604
lines changed

src/Microsoft.ML.Data/Evaluators/EvaluatorUtils.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -653,10 +653,10 @@ public static void ReconcileKeyValuesWithNoNames(IHostEnvironment env, IDataView
653653
ValueMapper<uint, uint> mapper =
654654
(ref uint src, ref uint dst) =>
655655
{
656-
if (src == 0 || src > keyCount)
656+
if (src > keyCount)
657657
dst = 0;
658658
else
659-
dst = src + 1;
659+
dst = src;
660660
};
661661
views[i] = LambdaColumnMapper.Create(env, "ReconcileKeyValues", views[i], columnName, columnName,
662662
views[i].Schema.GetColumnType(index), keyType, mapper);
@@ -866,7 +866,7 @@ private static IDataView AppendPerInstanceDataViews(IHostEnvironment env, string
866866
}
867867
else if (dvNumber == 0 && dv.Schema.HasKeyNames(i, type.KeyCount))
868868
firstDvKeyWithNamesColumns.Add(name);
869-
else if (type.KeyCount > 0 && name != labelColName)
869+
else if (type.KeyCount > 0 && name != labelColName && !dv.Schema.HasKeyNames(i, type.KeyCount))
870870
{
871871
// For any other key column (such as GroupId) we do not reconcile the key values, we only convert to U4.
872872
if (!firstDvKeyNoNamesColumns.ContainsKey(name))
@@ -901,7 +901,7 @@ private static IDataView AppendPerInstanceDataViews(IHostEnvironment env, string
901901
Func<IDataView, int, IDataView> keyToValue =
902902
(idv, i) =>
903903
{
904-
foreach (var keyCol in firstDvVectorKeyColumns.Prepend(labelColName))
904+
foreach (var keyCol in firstDvVectorKeyColumns.Concat(firstDvKeyWithNamesColumns).Prepend(labelColName))
905905
{
906906
if (keyCol == labelColName && labelColKeyValuesType == null)
907907
continue;

0 commit comments

Comments
 (0)