protected PredictedLabelScorerBase(ScorerArgumentsBase args, IHostEnvironment env, IDataView data, ISchemaBoundMapper mapper, RoleMappedSchema trainSchema, string registrationName, string scoreColKind, string scoreColName, Func <ColumnType, bool> outputTypeMatches, Func <ColumnType, ISchemaBoundRowMapper, ColumnType> getPredColType) : 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.Schema.TryGetColumnIndex(scoreColName, out scoreColIndex)) { throw Host.ExceptParam(nameof(scoreColName), "mapper does not contain a column '{0}'", scoreColName); } var scoreType = mapper.Schema.GetColumnType(scoreColIndex); Host.Check(outputTypeMatches(scoreType), "Unexpected predictor output type"); var predColType = getPredColType(scoreType, rowMapper); Bindings = BindingsImpl.Create(data.Schema, rowMapper, args.Suffix, scoreColKind, scoreColIndex, predColType); }
/// <summary> /// The <see cref="SignatureDataScorer"/> entry point for creating a <see cref="GenericScorer"/>. /// </summary> public 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); }