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
 protected PredictedLabelScorerBase(IHostEnvironment env, PredictedLabelScorerBase transform,
                                    IDataView newSource, string registrationName)
     : base(env, newSource, registrationName, transform.Bindable)
 {
     Bindings     = transform.Bindings.ApplyToSchema(newSource.Schema, Bindable, env);
     OutputSchema = Bindings.AsSchema;
 }
コード例 #3
0
        protected PredictedLabelScorerBase(IHost host, ModelLoadContext ctx, IDataView input,
                                           Func <ColumnType, bool> outputTypeMatches, Func <ColumnType, ISchemaBoundRowMapper, ColumnType> getPredColType)
            : base(host, ctx, input)
        {
            Host.AssertValue(ctx);
            Host.AssertValue(host);
            Host.AssertValue(outputTypeMatches);
            Host.AssertValue(getPredColType);

            Bindings = BindingsImpl.Create(ctx, input.Schema, host, Bindable, outputTypeMatches, getPredColType);
        }