protected override Delegate GetPredictionGetter(IRow input, int colSrc)
        {
            Contracts.AssertValue(input);
            Contracts.Assert(0 <= colSrc && colSrc < input.Schema.ColumnCount);

            var typeSrc = input.Schema.GetColumnType(colSrc);

            Contracts.Assert(typeSrc.IsVector && typeSrc.ItemType == NumberType.Float);
            Contracts.Assert(ValueMapper == null ||
                             typeSrc.VectorSize == ValueMapper.InputType.VectorSize || ValueMapper.InputType.VectorSize == 0);
            Contracts.Assert(Utils.Size(_quantiles) > 0);

            var featureGetter = input.GetGetter <VBuffer <Float> >(colSrc);
            var featureCount  = ValueMapper != null ? ValueMapper.InputType.VectorSize : 0;

            var quantiles = new Float[_quantiles.Length];

            for (int i = 0; i < quantiles.Length; i++)
            {
                quantiles[i] = (Float)_quantiles[i];
            }
            var map = _qpred.GetMapper(quantiles);

            var features = default(VBuffer <Float>);
            ValueGetter <VBuffer <Float> > del =
                (ref VBuffer <Float> value) =>
            {
                featureGetter(ref features);
                Contracts.Check(features.Length == featureCount || featureCount == 0);
                map(in features, ref value);
            };
Esempio n. 2
0
        protected override Delegate GetPredictionGetter(DataViewRow input, int colSrc)
        {
            Contracts.AssertValue(input);
            Contracts.Assert(0 <= colSrc && colSrc < input.Schema.Count);

            var column  = input.Schema[colSrc];
            var typeSrc = column.Type as VectorType;

            Contracts.Assert(typeSrc != null && typeSrc.ItemType == NumberDataViewType.Single);
            Contracts.Assert(ValueMapper == null ||
                             typeSrc.Size == ValueMapper.InputType.GetVectorSize() || ValueMapper.InputType.GetVectorSize() == 0);
            Contracts.Assert(Utils.Size(_quantiles) > 0);

            var featureGetter = input.GetGetter <VBuffer <float> >(column);
            var featureCount  = ValueMapper != null?ValueMapper.InputType.GetVectorSize() : 0;

            var quantiles = new float[_quantiles.Length];

            for (int i = 0; i < quantiles.Length; i++)
            {
                quantiles[i] = (float)_quantiles[i];
            }
            var map = _qpred.GetMapper(quantiles);

            var features = default(VBuffer <float>);
            ValueGetter <VBuffer <float> > del =
                (ref VBuffer <float> value) =>
            {
                featureGetter(ref features);
                Contracts.Check(features.Length == featureCount || featureCount == 0);
                map(in features, ref value);
            };