private void CheckInputColumnTypes(ISchema schema, out ColumnType labelType, out ColumnType scoreType,
                                           out ColumnMetadataInfo labelMetadata, out ColumnMetadataInfo scoreMetadata)
        {
            Host.AssertNonEmpty(ScoreCol);
            Host.AssertNonEmpty(LabelCol);

            var t = schema.GetColumnType(LabelIndex);

            if (!t.IsKnownSizeVector || (t.ItemType != NumberType.R4 && t.ItemType != NumberType.R8))
            {
                throw Host.Except("Label column '{0}' has type '{1}' but must be a known-size vector of R4 or R8", LabelCol, t);
            }
            labelType = new VectorType(t.ItemType.AsPrimitive, t.VectorSize);
            var slotNamesType = new VectorType(TextType.Instance, t.VectorSize);

            labelMetadata = new ColumnMetadataInfo(LabelCol);
            labelMetadata.Add(MetadataUtils.Kinds.SlotNames, new MetadataInfo <VBuffer <DvText> >(slotNamesType,
                                                                                                  CreateSlotNamesGetter(schema, LabelIndex, labelType.VectorSize, "True")));

            t = schema.GetColumnType(ScoreIndex);
            if (t.VectorSize == 0 || t.ItemType != NumberType.Float)
            {
                throw Host.Except("Score column '{0}' has type '{1}' but must be a known length vector of type R4", ScoreCol, t);
            }
            scoreType     = new VectorType(t.ItemType.AsPrimitive, t.VectorSize);
            scoreMetadata = new ColumnMetadataInfo(ScoreCol);
            scoreMetadata.Add(MetadataUtils.Kinds.SlotNames, new MetadataInfo <VBuffer <DvText> >(slotNamesType,
                                                                                                  CreateSlotNamesGetter(schema, ScoreIndex, scoreType.VectorSize, "Predicted")));
            scoreMetadata.Add(MetadataUtils.Kinds.ScoreColumnKind, new MetadataInfo <DvText>(TextType.Instance, GetScoreColumnKind));
            scoreMetadata.Add(MetadataUtils.Kinds.ScoreValueKind, new MetadataInfo <DvText>(TextType.Instance, GetScoreValueKind));
            scoreMetadata.Add(MetadataUtils.Kinds.ScoreColumnSetId,
                              new MetadataInfo <uint>(MetadataUtils.ScoreColumnSetIdType, GetScoreColumnSetId(schema)));
        }
        public override RowMapperColumnInfo[] GetOutputColumns()
        {
            var infos = new RowMapperColumnInfo[2];

            var slotNamesType = new VectorType(TextType.Instance, _scoreSize);
            var l1Metadata    = new ColumnMetadataInfo(L1);

            l1Metadata.Add(MetadataUtils.Kinds.SlotNames, new MetadataInfo <VBuffer <DvText> >(slotNamesType, CreateSlotNamesGetter(L1)));
            var l2Metadata = new ColumnMetadataInfo(L2);

            l2Metadata.Add(MetadataUtils.Kinds.SlotNames, new MetadataInfo <VBuffer <DvText> >(slotNamesType, CreateSlotNamesGetter(L2)));

            infos[L1Col] = new RowMapperColumnInfo(L1, _outputType, l1Metadata);
            infos[L2Col] = new RowMapperColumnInfo(L2, _outputType, l2Metadata);
            return(infos);
        }
        public override RowMapperColumnInfo[] GetOutputColumns()
        {
            var infos = new RowMapperColumnInfo[3];

            infos[ClusterIdCol] = new RowMapperColumnInfo(ClusterId, _types[ClusterIdCol], null);

            var slotNamesType = new VectorType(TextType.Instance, _numClusters);

            var sortedClusters = new ColumnMetadataInfo(SortedClusters);

            sortedClusters.Add(MetadataUtils.Kinds.SlotNames, new MetadataInfo <VBuffer <DvText> >(slotNamesType,
                                                                                                   CreateSlotNamesGetter(_numClusters, "Cluster")));
            var sortedClusterScores = new ColumnMetadataInfo(SortedClusterScores);

            sortedClusterScores.Add(MetadataUtils.Kinds.SlotNames, new MetadataInfo <VBuffer <DvText> >(slotNamesType,
                                                                                                        CreateSlotNamesGetter(_numClusters, "Score")));

            infos[SortedClusterCol]      = new RowMapperColumnInfo(SortedClusters, _types[SortedClusterCol], sortedClusters);
            infos[SortedClusterScoreCol] = new RowMapperColumnInfo(SortedClusterScores,
                                                                   _types[SortedClusterScoreCol], sortedClusterScores);
            return(infos);
        }
Esempio n. 4
0
 public RowMapperColumnInfo(string name, ColumnType type, ColumnMetadataInfo metadata)
 {
     Name     = name;
     ColType  = type;
     Metadata = metadata;
 }