public DataView(IHostEnvironment env, ArrayDataViewBuilder builder, int rowCount)
            {
                Contracts.AssertValue(env, "env");
                _host = env.Register("ArrayDataView");

                _host.AssertValue(builder);
                _host.Assert(rowCount >= 0);
                _host.Assert(builder._names.Count == builder._columns.Count);
                _columns = builder._columns.ToArray();

                var schemaCols = new Schema.Column[_columns.Length];

                for (int i = 0; i < schemaCols.Length; i++)
                {
                    var meta = new Schema.Metadata.Builder();

                    if (builder._getSlotNames.TryGetValue(builder._names[i], out var slotNamesGetter))
                    {
                        meta.AddSlotNames(_columns[i].Type.VectorSize, slotNamesGetter);
                    }

                    if (builder._getKeyValues.TryGetValue(builder._names[i], out var keyValueGetter))
                    {
                        meta.AddKeyValues(_columns[i].Type.KeyCount, TextType.Instance, keyValueGetter);
                    }
                    schemaCols[i] = new Schema.Column(builder._names[i], _columns[i].Type, meta.GetMetadata());
                }

                _schema   = new Schema(schemaCols);
                _rowCount = rowCount;
            }
Esempio n. 2
0
        public override Schema.Column[] GetOutputColumns()
        {
            var infos = new Schema.Column[2];

            infos[L1Col] = new Schema.Column(L1, NumberType.R8, null);
            infos[L2Col] = new Schema.Column(L2, NumberType.R8, null);
            return(infos);
        }
Esempio n. 3
0
        public override Schema.Column[] GetOutputColumns()
        {
            var infos = new Schema.Column[5];

            infos[LabelOutput] = new Schema.Column(LabelCol, _labelType, _labelMetadata);
            infos[ScoreOutput] = new Schema.Column(ScoreCol, _scoreType, _scoreMetadata);
            infos[L1Output]    = new Schema.Column(L1, NumberType.R8, null);
            infos[L2Output]    = new Schema.Column(L2, NumberType.R8, null);
            infos[DistCol]     = new Schema.Column(Dist, NumberType.R8, null);
            return(infos);
        }
Esempio n. 4
0
        public override Schema.Column[] GetOutputColumns()
        {
            var infos = new Schema.Column[2];

            var slotNamesType = new VectorType(TextType.Instance, _scoreSize);
            var l1Metadata    = new Schema.Metadata.Builder();

            l1Metadata.AddSlotNames(_scoreSize, CreateSlotNamesGetter(L1));

            var l2Metadata = new Schema.Metadata.Builder();

            l2Metadata.AddSlotNames(_scoreSize, CreateSlotNamesGetter(L2));

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

            infos[ClusterIdCol] = new Schema.Column(ClusterId, _types[ClusterIdCol], null);

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

            var sortedClusters = new Schema.Metadata.Builder();

            sortedClusters.AddSlotNames(slotNamesType.VectorSize, CreateSlotNamesGetter(_numClusters, "Cluster"));

            var sortedClusterScores = new Schema.Metadata.Builder();

            sortedClusterScores.AddSlotNames(slotNamesType.VectorSize, CreateSlotNamesGetter(_numClusters, "Score"));

            infos[SortedClusterCol]      = new Schema.Column(SortedClusters, _types[SortedClusterCol], sortedClusters.GetMetadata());
            infos[SortedClusterScoreCol] = new Schema.Column(SortedClusterScores, _types[SortedClusterScoreCol], sortedClusterScores.GetMetadata());
            return(infos);
        }
Esempio n. 6
0
        private static void Add(Dictionary <string, List <Schema.Column> > map, ColumnRole role, Schema.Column column)
        {
            Contracts.AssertValue(map);
            Contracts.AssertNonEmpty(role.Value);

            if (!map.TryGetValue(role.Value, out var list))
            {
                list = new List <Schema.Column>();
                map.Add(role.Value, list);
            }
            list.Add(column);
        }