Ejemplo n.º 1
0
        internal DataReaderEstimator(IHostEnvironment env, IDataReaderEstimator <TIn, TDataReader> estimator, StaticSchemaShape shape)
            : base(env, shape)
        {
            Env.AssertValue(estimator);

            AsDynamic = estimator;
            Shape.Check(Env, AsDynamic.GetOutputSchema());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a composite reader estimator by appending an estimator to a reader estimator.
        /// </summary>
        public static CompositeReaderEstimator <TSource, TTrans> Append <TSource, TTrans>(
            this IDataReaderEstimator <TSource, IDataReader <TSource> > start, IEstimator <TTrans> estimator)
            where TTrans : class, ITransformer
        {
            Contracts.CheckValue(start, nameof(start));
            Contracts.CheckValue(estimator, nameof(estimator));

            return(new CompositeReaderEstimator <TSource, ITransformer>(start).Append(estimator));
        }
        public CompositeReaderEstimator(IDataReaderEstimator <TSource, IDataReader <TSource> > start, EstimatorChain <TLastTransformer> estimatorChain = null)
        {
            Contracts.CheckValue(start, nameof(start));
            Contracts.CheckValueOrNull(estimatorChain);

            _start          = start;
            _estimatorChain = estimatorChain ?? new EstimatorChain <TLastTransformer>();

            // REVIEW: enforce that estimator chain can read the reader's schema.
            // Right now it throws.
            // GetOutputSchema();
        }
Ejemplo n.º 4
0
        public static DataReaderEstimator <TIn, T, TReader> AssertStatic <TIn, [IsShape] T, TReader>(
            this IDataReaderEstimator <TIn, TReader> readerEstimator, IHostEnvironment env,
            Func <SchemaAssertionContext, T> outputDecl)
            where TReader : class, IDataReader <TIn>
        {
            Contracts.CheckValue(env, nameof(env));
            env.CheckValue(readerEstimator, nameof(readerEstimator));
            env.CheckValue(outputDecl, nameof(outputDecl));

            var schema = StaticSchemaShape.Make <T>(outputDecl.Method.ReturnParameter);

            return(new DataReaderEstimator <TIn, T, TReader>(env, readerEstimator, schema));
        }
Ejemplo n.º 5
0
 public static IDataView FitAndRead <TSource>(this IDataReaderEstimator <TSource, IDataReader <TSource> > est, TSource source)
 => est.Fit(source).Read(source);