Ejemplo n.º 1
0
        /// <summary>
        /// Create an instance of <see cref="PredictionFunction{TSrc, TDst}"/>.
        /// </summary>
        /// <param name="env">The host environment.</param>
        /// <param name="transformer">The model (transformer) to use for prediction.</param>
        public PredictionFunction(IHostEnvironment env, ITransformer transformer)
        {
            Contracts.CheckValue(env, nameof(env));
            env.CheckValue(transformer, nameof(transformer));

            IDataView dv = env.CreateDataView(new TSrc[0]);

            _engine = env.CreatePredictionEngine <TSrc, TDst>(transformer);
        }
Ejemplo n.º 2
0
            public PredictionEngineExample(string modelName)
            {
                _env = EnvHelper.NewTestEnvironment();

                var view = DataViewConstructionUtils.CreateFromEnumerable(_env, new FloatVectorInput[] { });
                var pipe = DataViewConstructionUtils.LoadPipeWithPredictor(_env, File.OpenRead(modelName),
                                                                           new EmptyDataView(_env, view.Schema));
                var transformer = new TransformWrapper(_env, pipe);

                _predictor = _env.CreatePredictionEngine <FloatVectorInput, FloatOutput>(transformer);
            }
Ejemplo n.º 3
0
        public MyPredictionEngine(IHostEnvironment env, ITransformer pipe)
        {
            IDataView dv = env.CreateDataView(new TSrc[0]);

            _engine = env.CreatePredictionEngine <TSrc, TDst>(pipe.Transform(dv));
        }