Esempio n. 1
0
        public void UpdateWine(WineData wineData, WineBarcode wineBarData, double productArticle) //Info passed back to Form1 where it is linked to the textboxes
        {
            //LINQ query to the database where the products in the update textboxes are populated back to the DB
            using (var context = new GroceryTestDBEntities())
            {
                var query = from s in context.WineDatas
                            where s.Article == productArticle
                            select s;
                var query1 = from s in context.WineBarcodes
                             where s.Article == productArticle
                             select s;
                var wineProducts            = query.FirstOrDefault();
                var wineProductsWithBarcode = query1.FirstOrDefault();

                wineProducts.Article             = wineData.Article;
                wineProducts.Article_Description = wineData.Article_Description;
                wineProductsWithBarcode.Article  = wineBarData.Article;
                wineProductsWithBarcode.Barcode  = wineBarData.Barcode;
                wineProducts.Storage_Bin         = wineData.Storage_Bin;
                wineProducts.Department          = wineData.Department;
                wineProducts.Sub_Department      = wineData.Sub_Department;

                context.SaveChanges();
            }
        }
Esempio n. 2
0
        public float Post([FromBody] WineData wineData)
        {
            var predictionEngine = _model.CreatePredictionEngine <WineData, WinePrediction>(_context);

            var prediction = predictionEngine.Predict(wineData);

            return(prediction.PredictedQuality);
        }
Esempio n. 3
0
        public async Task <string> Predict(WineData wineData)
        {
            var options = new JsonSerializerOptions
            {
                PropertyNameCaseInsensitive = true
            };

            var jsonString = JsonSerializer.Serialize(wineData, options);

            var inputContent = new StringContent(jsonString, Encoding.UTF8, "application/json");

            var response = await _client.PostAsync("model", inputContent);

            var predictedQuality = await response.Content.ReadAsStringAsync();

            return(predictedQuality);
        }
        private void UpdateWineProduct()
        {
            // Update the products in the DB based off what is entered into the update textboxes
            WineData    wineProducts            = new WineData();
            WineBarcode wineProductsWithBarcode = new WineBarcode();
            double      article = Convert.ToDouble(txtUpdateArticle.Text);

            wineProducts.Article             = Convert.ToDouble(txtUpdateArticle.Text);
            wineProducts.Article_Description = txtUpdateDesc.Text;
            wineProductsWithBarcode.Article  = Convert.ToDouble(txtUpdateArticle.Text);
            wineProductsWithBarcode.Barcode  = Convert.ToDouble(txtUpdateBarcode.Text);
            wineProducts.Storage_Bin         = txtUpdateStorage.Text;
            wineProducts.Department          = txtUpdateDept.Text;
            wineProducts.Sub_Department      = txtUpdateSubDept.Text;

            myLinqUpdateCalls.UpdateWine(wineProducts, wineProductsWithBarcode, article);
            ClearAddTextBoxes();
            ClearUpdateTextBoxes();
            RefreshDGV();
        }
Esempio n. 5
0
        private async Task ExecutePredictCommand()
        {
            var data = new WineData
            {
                Type               = WineType,
                FixedAcidity       = FixedAcidity,
                VolatileAcidity    = VolatileAcidity,
                CitricAcid         = CitricAcid,
                ResidualSugar      = ResidualSugar,
                Chlorides          = Chlorides,
                FreeSulfurDioxide  = FreeSulferDioxide,
                TotalSulfurDioxide = TotalSulferDioxide,
                Density            = Density,
                Ph        = Ph,
                Sulphates = Sulphates,
                Alcohol   = Alcohol
            };

            var quality = await _predictionService.Predict(data);

            MessagingCenter.Send(this, "Predict", quality);
        }
        private void AddWineProduct()
        {
            // Adds products to the DB based off what is entered into the text boxes
            using (var context = new GroceryTestDBEntities())
            {
                var products       = new WineData();
                var productbarcode = new WineBarcode();
                products.Article             = Convert.ToDouble(txtAddArticle.Text);
                products.Article_Description = txtAddDesc.Text;
                productbarcode.Article       = Convert.ToDouble(txtAddArticle.Text);
                productbarcode.Barcode       = Convert.ToDouble(txtAddBarcode.Text);
                products.Storage_Bin         = txtAddStorage.Text;
                products.Department          = txtAddDept.Text;
                products.Sub_Department      = txtAddSubDept.Text;
                MessageBox.Show(products.Article_Description + " was added to the Database.");

                context.WineDatas.Add(products);
                context.WineBarcodes.Add(productbarcode);
                context.SaveChanges();

                ClearAddTextBoxes();
            }
        }
Esempio n. 7
0
        public float Post([FromBody] WineData wineData)
        {
            var prediction = _predictionEnginePool.Predict(wineData);

            return(prediction.PredictedQuality);
        }
Esempio n. 8
0
        static void Predict(PredictionModel <WineData, WinePrediction> model)
        {
            using (var environment = new TlcEnvironment())
            {
                var textLoader = new Microsoft.ML.Data.TextLoader(TestDataPath).CreateFrom <WineData>(useHeader: true, separator: ',', trimWhitespace: false);
                var experiment = environment.CreateExperiment();
                var output     = textLoader.ApplyStep(null, experiment) as ILearningPipelineDataStep;

                experiment.Compile();
                textLoader.SetInput(environment, experiment);
                experiment.Run();
                var data      = experiment.GetOutput(output.Data);
                var wineDatas = new List <WineData>();
                using (var cursor = data.GetRowCursor((a => true)))
                {
                    var getters = new ValueGetter <float>[] {
                        cursor.GetGetter <float>(0),
                        cursor.GetGetter <float>(1),
                        cursor.GetGetter <float>(2),
                        cursor.GetGetter <float>(3),
                        cursor.GetGetter <float>(4),
                        cursor.GetGetter <float>(5),
                        cursor.GetGetter <float>(6),
                        cursor.GetGetter <float>(7),
                        cursor.GetGetter <float>(8),
                        cursor.GetGetter <float>(9),
                        cursor.GetGetter <float>(10),
                        cursor.GetGetter <float>(11),
                        cursor.GetGetter <float>(12)
                    };

                    while (cursor.MoveNext())
                    {
                        float value0  = 0;
                        float value1  = 0;
                        float value2  = 0;
                        float value3  = 0;
                        float value4  = 0;
                        float value5  = 0;
                        float value6  = 0;
                        float value7  = 0;
                        float value8  = 0;
                        float value9  = 0;
                        float value10 = 0;
                        float value11 = 0;
                        float value12 = 0;
                        getters[0](ref value0);
                        getters[1](ref value1);
                        getters[2](ref value2);
                        getters[3](ref value3);
                        getters[4](ref value4);
                        getters[5](ref value5);
                        getters[6](ref value6);
                        getters[7](ref value7);
                        getters[8](ref value8);
                        getters[9](ref value9);
                        getters[10](ref value10);
                        getters[11](ref value11);
                        getters[12](ref value12);

                        var wdata = new WineData()
                        {
                            FixedAcidity       = value0,
                            VolatileAcidity    = value1,
                            CitricACID         = value2,
                            ResidualSugar      = value3,
                            Chlorides          = value4,
                            FreeSulfurDioxide  = value5,
                            TotalSulfurDioxide = value6,
                            Density            = value7,
                            PH        = value8,
                            Sulphates = value9,
                            Alcohol   = value10,
                            Quality   = value11,
                            Id        = value12,
                        };
                        wineDatas.Add(wdata);
                    }
                }
                var predictions = model.Predict(wineDatas);

                var wineDataAndPredictions = wineDatas.Zip(predictions, (wineData, prediction) => (wineData, prediction));
                Console.WriteLine($"Wine Id: {wineDataAndPredictions.Last().wineData.Id}, Quality: {wineDataAndPredictions.Last().wineData.Quality} | Prediction: {  wineDataAndPredictions.Last().prediction.PredictionQuality}");
                Console.WriteLine();
            }
        }
Esempio n. 9
0
 public void Predict(WineData iris)
 {
 }