internal static ISchemaBoundMapper WrapCore <T>(IHostEnvironment env, ISchemaBoundMapper mapper, RoleMappedSchema trainSchema) { Contracts.AssertValue(env); env.AssertValue(mapper); env.AssertValue(trainSchema); env.Assert(mapper is ISchemaBoundRowMapper); // Key values from the training schema label, will map to slot names of the score output. var type = trainSchema.Label.Value.Annotations.Schema.GetColumnOrNull(AnnotationUtils.Kinds.KeyValues)?.Type; env.AssertValue(type); env.Assert(type is VectorDataViewType); // Wrap the fetching of the metadata as a simple getter. ValueGetter <VBuffer <T> > getter = (ref VBuffer <T> value) => { trainSchema.Label.Value.GetKeyValues(ref value); }; var resultMapper = mapper; if (CanWrapTrainingLabels(resultMapper, type)) { resultMapper = LabelNameBindableMapper.CreateBound <T>(env, (ISchemaBoundRowMapper)resultMapper, type as VectorDataViewType, getter, AnnotationUtils.Kinds.TrainingLabelValues, CanWrapTrainingLabels); } if (CanWrapSlotNames(resultMapper, type)) { resultMapper = LabelNameBindableMapper.CreateBound <T>(env, (ISchemaBoundRowMapper)resultMapper, type as VectorDataViewType, getter, AnnotationUtils.Kinds.SlotNames, CanWrapSlotNames); } return(resultMapper); }
internal static ISchemaBoundMapper WrapCore <T>(IHostEnvironment env, ISchemaBoundMapper mapper, RoleMappedSchema trainSchema) { Contracts.AssertValue(env); env.AssertValue(mapper); env.AssertValue(trainSchema); env.Assert(mapper is ISchemaBoundRowMapper); // Key values from the training schema label, will map to slot names of the score output. var type = trainSchema.Label.Value.Metadata.Schema.GetColumnOrNull(MetadataUtils.Kinds.KeyValues)?.Type; env.AssertValue(type); env.Assert(type is VectorType); // Wrap the fetching of the metadata as a simple getter. ValueGetter <VBuffer <T> > getter = (ref VBuffer <T> value) => { trainSchema.Label.Value.Metadata.GetValue(MetadataUtils.Kinds.KeyValues, ref value); }; return(LabelNameBindableMapper.CreateBound <T>(env, (ISchemaBoundRowMapper)mapper, type as VectorType, getter, MetadataUtils.Kinds.SlotNames, CanWrap)); }