Skip to content

Commit

Permalink
Introduce VBufferEditor and hide VBuffer.Count (#1580)
Browse files Browse the repository at this point in the history
* Implement VBuffer master plan WIP #1

* Getting everything to build and tests passing

* Keep moving to the master plan of VBuffer.

* Remove the rest of the VBuffer.Count usages in ML.Data

* Remove the rest of the VBuffer.Count usages and make VBuffer.Count private.

* Fix two failing tests.

* Fix FastTreeBinaryClassificationCategoricalSplitTest by remembering the underlying arrays in the column buffer in Transposer.

Also enable a Transposer test, since it passes.
  • Loading branch information
eerhardt committed Nov 16, 2018
1 parent 8a45f37 commit cb9effc
Show file tree
Hide file tree
Showing 90 changed files with 1,811 additions and 1,717 deletions.
19 changes: 11 additions & 8 deletions src/Microsoft.ML.Core/Data/MetadataUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,9 @@ public static void GetSlotNames(RoleMappedSchema schema, RoleMappedSchema.Column

IReadOnlyList<ColumnInfo> list;
if ((list = schema?.GetColumns(role)) == null || list.Count != 1 || !schema.Schema.HasSlotNames(list[0].Index, vectorSize))
slotNames = new VBuffer<ReadOnlyMemory<char>>(vectorSize, 0, slotNames.Values, slotNames.Indices);
{
VBufferUtils.Resize(ref slotNames, vectorSize, 0);
}
else
schema.Schema.GetMetadata(Kinds.SlotNames, list[0].Index, ref slotNames);
}
Expand Down Expand Up @@ -447,21 +449,22 @@ public static bool TryGetCategoricalFeatureIndices(Schema schema, int colIndex,
{
int previousEndIndex = -1;
isValid = true;
for (int i = 0; i < catIndices.Values.Length; i += 2)
var catIndicesValues = catIndices.GetValues();
for (int i = 0; i < catIndicesValues.Length; i += 2)
{
if (catIndices.Values[i] > catIndices.Values[i + 1] ||
catIndices.Values[i] <= previousEndIndex ||
catIndices.Values[i] >= columnSlotsCount ||
catIndices.Values[i + 1] >= columnSlotsCount)
if (catIndicesValues[i] > catIndicesValues[i + 1] ||
catIndicesValues[i] <= previousEndIndex ||
catIndicesValues[i] >= columnSlotsCount ||
catIndicesValues[i + 1] >= columnSlotsCount)
{
isValid = false;
break;
}

previousEndIndex = catIndices.Values[i + 1];
previousEndIndex = catIndicesValues[i + 1];
}
if (isValid)
categoricalFeatures = catIndices.Values.Select(val => val).ToArray();
categoricalFeatures = catIndicesValues.ToArray();
}
}

Expand Down
Loading

0 comments on commit cb9effc

Please sign in to comment.