public override IEstimator <ITransformer> Reconcile(IHostEnvironment env, PipelineColumn[] toOutput, IReadOnlyDictionary <PipelineColumn, string> inputNames, IReadOnlyDictionary <PipelineColumn, string> outputNames, IReadOnlyCollection <string> usedNames) { var infos = new TermTransform.ColumnInfo[toOutput.Length]; Action <TermTransform> onFit = null; for (int i = 0; i < toOutput.Length; ++i) { var tcol = (ITermCol)toOutput[i]; infos[i] = new TermTransform.ColumnInfo(inputNames[tcol.Input], outputNames[toOutput[i]], tcol.Config.Max, (TermTransform.SortOrder)tcol.Config.Order); if (tcol.Config.OnFit != null) { int ii = i; // Necessary because if we capture i that will change to toOutput.Length on call. onFit += tt => tcol.Config.OnFit(tt.GetTermMap(ii)); } } var est = new TermEstimator(env, infos); if (onFit == null) { return(est); } return(est.WithOnFitDelegate(onFit)); }
internal void WrapTermWithDelegate(Action <TermTransform> onFit) { _term = (TermEstimator)_term.WithOnFitDelegate(onFit); }