Ejemplo n.º 1
0
        // Przewiduje poprawną cenę oferowanej książki przez system analityczny.
        public ContentResult <AnalyticModelPrediction> AnalizeOffer(FormalizedOffer offer)
        {
            var mlContext = new MLContext(0);

            ITransformer model;

            using (var stream = new FileStream(hostingEnvironment.ContentRootPath + "/private_static/model.zip", FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                model = mlContext.Model.Load(stream);
            }

            var toAnalize = new AnalyticModel
            {
                AuthorPopularity = offer.AuthorPopularity,
                Condition        = offer.Condition,
                Category         = offer.Category,
                Language         = offer.Language,
                IsEbook          = offer.IsEbook,
                WritingTime      = offer.WritingTime,
                PrintingTime     = offer.PrintingTime
            };

            var predictionEngine = model.CreatePredictionEngine <AnalyticModel, AnalyticModelPrediction>(mlContext);
            var predictedPrice   = predictionEngine.Predict(toAnalize);

            return(new ContentResult <AnalyticModelPrediction>
            {
                Content = predictedPrice
            });
        }
Ejemplo n.º 2
0
        public IActionResult AnalizeOffer([FromBody] FormalizedOffer offer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var price = offerService.AnalizeOffer(offer).Content;

            return(Ok(price));
        }