Ejemplo n.º 1
0
 private static Func <Schema, IRowToRowMapper> StreamChecker(IHostEnvironment env, Stream modelStream)
 {
     env.CheckValue(modelStream, nameof(modelStream));
     return(schema =>
     {
         var pipe = DataViewConstructionUtils.LoadPipeWithPredictor(env, modelStream, new EmptyDataView(env, schema));
         var transformer = new TransformWrapper(env, pipe);
         env.CheckParam(transformer.IsRowToRowMapper, nameof(transformer), "Must be a row to row mapper");
         return transformer.GetRowToRowMapper(schema);
     });
 }
Ejemplo n.º 2
0
        internal BatchPredictionEngine(IHostEnvironment env, Stream modelStream, bool ignoreMissingColumns,
                                       SchemaDefinition inputSchemaDefinition = null, SchemaDefinition outputSchemaDefinition = null)
        {
            Contracts.AssertValue(env);
            Contracts.AssertValue(modelStream);
            Contracts.AssertValueOrNull(inputSchemaDefinition);
            Contracts.AssertValueOrNull(outputSchemaDefinition);

            // Initialize pipe.
            _srcDataView = DataViewConstructionUtils.CreateFromEnumerable(env, new TSrc[] { }, inputSchemaDefinition);
            var pipe = DataViewConstructionUtils.LoadPipeWithPredictor(env, modelStream, _srcDataView);

            _pipeEngine = new PipeEngine <TDst>(env, pipe, ignoreMissingColumns, outputSchemaDefinition);
        }