internal static IDataTransform Create(IHostEnvironment env, Arguments args, IDataView input) { Contracts.CheckValue(env, nameof(env)); var h = env.Register("Categorical"); h.CheckValue(args, nameof(args)); h.CheckValue(input, nameof(input)); h.CheckUserArg(Utils.Size(args.Column) > 0, nameof(args.Column)); var columns = new List <CategoricalHashEstimator.ColumnInfo>(); foreach (var column in args.Column) { var col = new CategoricalHashEstimator.ColumnInfo( column.Source ?? column.Name, column.Name, column.OutputKind ?? args.OutputKind, column.HashBits ?? args.HashBits, column.Seed ?? args.Seed, column.Ordered ?? args.Ordered, column.InvertHash ?? args.InvertHash); columns.Add(col); } return(new CategoricalHashEstimator(env, columns.ToArray()).Fit(input).Transform(input) as IDataTransform); }
public override IEstimator <ITransformer> Reconcile(IHostEnvironment env, PipelineColumn[] toOutput, IReadOnlyDictionary <PipelineColumn, string> inputNames, IReadOnlyDictionary <PipelineColumn, string> outputNames, IReadOnlyCollection <string> usedNames) { var infos = new CategoricalHashEstimator.ColumnInfo[toOutput.Length]; for (int i = 0; i < toOutput.Length; ++i) { var tcol = (ICategoricalCol)toOutput[i]; infos[i] = new CategoricalHashEstimator.ColumnInfo(inputNames[tcol.Input], outputNames[toOutput[i]], (CategoricalTransform.OutputKind)tcol.Config.OutputKind, tcol.Config.HashBits, tcol.Config.Seed, tcol.Config.Ordered, tcol.Config.InvertHash); } return(new CategoricalHashEstimator(env, infos)); }