Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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
19 changes: 19 additions & 0 deletions src/Microsoft.ML.Data/DataLoadSave/TransformerChain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,25 @@ public DataViewSchema GetOutputSchema(DataViewSchema inputSchema)
return s;
}

[BestFriend]
internal TransformerChain<ITransformer> RewindToLastPredictionTransformer()
{
int lastPredictorIndex = 0;
Comment thread
najeeb-kazmi marked this conversation as resolved.
Outdated
for (int i = _transformers.Length; i > 0; i--)
{
var current = _transformers[i - 1];
if (current is IPredictionTransformer<IPredictorProducing<float>>
|| current is IPredictionTransformer<IPredictorProducing<VBuffer<float>>>)
{
lastPredictorIndex = i;
break;
}
}
Contracts.Assert(lastPredictorIndex != 0, "No predictor found in the model.");
Comment thread
najeeb-kazmi marked this conversation as resolved.
Outdated
var predictorChain = _transformers.Take(lastPredictorIndex).ToArray();
return new TransformerChain<ITransformer>(predictorChain);
}

public IDataView Transform(IDataView input)
{
Contracts.CheckValue(input, nameof(input));
Expand Down
Loading