/// <summary> /// Create a trainer. /// </summary> /// <param name="env">host</param> /// <param name="settings">trainer description as a string such <pre>ova{p=lr}</pre></param> /// <param name="extraArgs">additional arguments</param> public static ITrainerExtended CreateTrainer(IHostEnvironment env, string settings, params object[] extraArgs) { var sc = SubComponent.Parse <ITrainer, SignatureTrainer>(settings); var inst = sc.CreateInstance(env, extraArgs); return(new ExtendedTrainer(inst, sc.Kind)); }
private static TRes CreateInstance <TRes, TSig>(IHostEnvironment env, string settings, out string loadName, params object[] extraArgs) where TRes : class { Contracts.AssertValue(env); env.AssertValue(settings, "settings"); var sc = SubComponent.Parse <TRes, TSig>(settings); loadName = sc.Kind; return(sc.CreateInstance(env, extraArgs)); }
/// <summary> /// Creates a data scorer from the 'LoadName{settings}' string. /// </summary> /// <param name="env">The host environment to use.</param> /// <param name="settings">The settings string.</param> /// <param name="data">The data to score.</param> /// <param name="predictor">The predictor to score.</param> /// <param name="trainSchema">The training data schema from which the scorer can optionally extract /// additional information, e.g., label names. If this is <c>null</c>, no information will be /// extracted.</param> /// <returns>The scored data.</returns> public static IDataScorerTransform CreateScorer(this IHostEnvironment env, string settings, RoleMappedData data, Predictor predictor, RoleMappedSchema trainSchema = null) { Contracts.CheckValue(env, nameof(env)); env.CheckValue(data, nameof(data)); env.CheckValue(predictor, nameof(predictor)); env.CheckValueOrNull(trainSchema); var subComponent = SubComponent.Parse <IDataScorerTransform, SignatureDataScorer>(settings); var bindable = ScoreUtils.GetSchemaBindableMapper(env, predictor.Pred, subComponent); var mapper = bindable.Bind(env, data.Schema); return(CreateCore <IDataScorerTransform, SignatureDataScorer>(env, settings, data.Data, mapper, trainSchema)); }