public static IDataScorerTransform GetScorer( TScorerFactory scorer, IPredictor predictor, IDataView input, string featureColName, string groupColName, IEnumerable <KeyValuePair <RoleMappedSchema.ColumnRole, string> > customColumns, IHostEnvironment env, RoleMappedSchema trainSchema, IComponentFactory <IPredictor, ISchemaBindableMapper> mapperFactory = null) { Contracts.CheckValue(env, nameof(env)); env.CheckValueOrNull(scorer); env.CheckValue(predictor, nameof(predictor)); env.CheckValue(input, nameof(input)); env.CheckValueOrNull(featureColName); env.CheckValueOrNull(groupColName); env.CheckValueOrNull(customColumns); env.CheckValueOrNull(trainSchema); var schema = new RoleMappedSchema(input.Schema, label: null, feature: featureColName, group: groupColName, custom: customColumns, opt: true); var sc = GetScorerComponentAndMapper(predictor, scorer, schema, env, mapperFactory, out var mapper); return(sc.CreateComponent(env, input, mapper, trainSchema)); }
/// <summary> /// Determines the scorer component factory (if the given one is null or empty), and creates the schema bound mapper. /// </summary> private static TScorerFactory GetScorerComponentAndMapper( IPredictor predictor, TScorerFactory scorerFactory, RoleMappedSchema schema, IHostEnvironment env, IComponentFactory<IPredictor, ISchemaBindableMapper> mapperFactory, out ISchemaBoundMapper mapper) { Contracts.AssertValue(env); var bindable = GetSchemaBindableMapper(env, predictor, mapperFactory, scorerFactory as ICommandLineComponentFactory); env.AssertValue(bindable); mapper = bindable.Bind(env, schema); if (scorerFactory != null) return scorerFactory; return GetScorerComponent(mapper); }