public static Estimator <TIn, TOut, TTrans> AssertStatic <[IsShape] TIn, [IsShape] TOut, TTrans>(
            this IEstimator <TTrans> estimator, IHostEnvironment env,
            Func <SchemaAssertionContext, TIn> inputDecl,
            Func <SchemaAssertionContext, TOut> outputDecl)
            where TTrans : class, ITransformer
        {
            Contracts.CheckValue(env, nameof(env));
            env.CheckValue(estimator, nameof(estimator));
            env.CheckValue(inputDecl, nameof(inputDecl));
            env.CheckValue(outputDecl, nameof(outputDecl));

            var inSchema  = StaticSchemaShape.Make <TIn>(inputDecl.Method.ReturnParameter);
            var outSchema = StaticSchemaShape.Make <TOut>(outputDecl.Method.ReturnParameter);

            return(new Estimator <TIn, TOut, TTrans>(env, estimator, inSchema, outSchema));
        }
Beispiel #2
0
 internal Estimator(IHostEnvironment env, IEstimator <TTransformer> estimator, StaticSchemaShape inShape, StaticSchemaShape outShape)
     : base(env, outShape)
 {
     Env.CheckValue(estimator, nameof(estimator));
     AsDynamic = estimator;
     _inShape  = inShape;
     // Our ability to check estimators at constructor time is somewaht limited. During fit though we could.
     // Fortunately, estimators are one of the least likely things that users will freqeuently declare the
     // types of on their own.
 }
 internal Transformer(IHostEnvironment env, TTransformer transformer, StaticSchemaShape inShape, StaticSchemaShape outShape)
     : base(env, outShape)
 {
     Env.AssertValue(transformer);
     Env.AssertValue(inShape);
     AsDynamic = transformer;
     _inShape  = inShape;
     // The ability to check at runtime is limited. We could check during transformation time on the input data view.
 }
Beispiel #4
0
        internal DataReaderEstimator(IHostEnvironment env, IDataReaderEstimator <TIn, TDataReader> estimator, StaticSchemaShape shape)
            : base(env, shape)
        {
            Env.AssertValue(estimator);

            AsDynamic = estimator;
            Shape.Check(Env, AsDynamic.GetOutputSchema());
        }