Beispiel #1
0
        /// <summary>
        /// This emits a warning if there is Normalizer sub-model.
        /// </summary>
        public static bool WarnOnOldNormalizer(ModelLoadContext ctx, Type typePredictor, IChannelProvider provider)
        {
            Contracts.CheckValue(provider, nameof(provider));
            provider.CheckValue(ctx, nameof(ctx));
            provider.CheckValue(typePredictor, nameof(typePredictor));

            if (!ctx.ContainsModel(@"Normalizer"))
                return false;
            using (var ch = provider.Start("WarnNormalizer"))
            {
                ch.Warning(NormalizerWarningFormat, typePredictor, Environment.NewLine);
                ch.Done();
            }
            return true;
        }
        /// <summary>
        /// Utility to take a cursor, and get a shuffled version of this cursor.
        /// </summary>
        public static IRowCursor GetShuffledCursor(IChannelProvider provider, int poolRows, IRowCursor cursor, IRandom rand)
        {
            Contracts.CheckValue(provider, nameof(provider));

            provider.CheckParam(poolRows > 0, nameof(poolRows), "Must be positive");
            provider.CheckValue(cursor, nameof(cursor));
            // REVIEW: In principle, we could limit this check to only active columns,
            // if we extend the use of this utility.
            provider.CheckParam(CanShuffleAll(cursor.Schema), nameof(cursor), "Cannot shuffle a cursor with some uncachable columns");
            provider.CheckValue(rand, nameof(rand));

            if (poolRows == 1)
            {
                return(cursor);
            }
            return(new RowCursor(provider, poolRows, cursor, rand));
        }