private protected PredictedLabelScorerBase(ScorerArgumentsBase args, IHostEnvironment env, IDataView data,
                                                   ISchemaBoundMapper mapper, RoleMappedSchema trainSchema, string registrationName, string scoreColKind, string scoreColName,
                                                   Func <DataViewType, bool> outputTypeMatches, Func <DataViewType, ISchemaBoundRowMapper, DataViewType> getPredColType, string predictedLabelColumnName = DefaultColumnNames.PredictedLabel)
            : base(env, data, registrationName, Contracts.CheckRef(mapper, nameof(mapper)).Bindable)
        {
            Host.CheckValue(args, nameof(args));
            Host.CheckNonEmpty(scoreColKind, nameof(scoreColKind));
            Host.CheckNonEmpty(scoreColName, nameof(scoreColName));
            Host.CheckValue(outputTypeMatches, nameof(outputTypeMatches));
            Host.CheckValue(getPredColType, nameof(getPredColType));

            var rowMapper = mapper as ISchemaBoundRowMapper;

            Host.CheckParam(rowMapper != null, nameof(mapper), "mapper should implement " + nameof(ISchemaBoundRowMapper));

            int scoreColIndex;

            if (!mapper.OutputSchema.TryGetColumnIndex(scoreColName, out scoreColIndex))
            {
                throw Host.ExceptParam(nameof(scoreColName), "mapper does not contain a column '{0}'", scoreColName);
            }

            var scoreType = mapper.OutputSchema[scoreColIndex].Type;

            Host.Check(outputTypeMatches(scoreType), "Unexpected predictor output type");
            var predColType = getPredColType(scoreType, rowMapper);

            Bindings     = BindingsImpl.Create(data.Schema, rowMapper, args.Suffix, scoreColKind, scoreColIndex, predColType, predictedLabelColumnName);
            OutputSchema = Bindings.AsSchema;
        }
예제 #2
0
        internal GenericScorer(IHostEnvironment env, ScorerArgumentsBase args, IDataView data,
                               ISchemaBoundMapper mapper, RoleMappedSchema trainSchema)
            : base(env, data, RegistrationName, Contracts.CheckRef(mapper, nameof(mapper)).Bindable)
        {
            Host.CheckValue(args, nameof(args));
            Host.AssertValue(data, "data");
            Host.AssertValue(mapper, "mapper");

            var rowMapper = mapper as ISchemaBoundRowMapper;

            Host.CheckParam(rowMapper != null, nameof(mapper), "mapper should implement ISchemaBoundRowMapper");
            _bindings    = Bindings.Create(data.Schema, rowMapper, args.Suffix);
            OutputSchema = _bindings.AsSchema;
        }