Пример #1
0
        private void Predict()
        {
            DataGridRow row = DataGridExtension.GetRow(dataGridPredict, 0);

            List <double> values = new List <double>();

            for (int i = 0; i < dataGridPredict.Columns.Count; i++)
            {
                TextBlock cellContent = dataGridPredict.Columns[i].GetCellContent(row) as TextBlock;
                if (cellContent != null)
                {
                    values.Add(double.Parse(cellContent.Text, CultureInfo.InvariantCulture));
                }
            }

            if (values.Count != AttrCount - 1)
            {
                throw new Exception("Entered incorrect values");
            }

            Matrix x = new Matrix(AttrCount, 1);

            x[0, 0] = 1;
            for (int i = 0; i < values.Count; i++)
            {
                x[i + 1, 0] = values[i];
            }

            Matrix transp = Matrix.Transpose(theta);
            Matrix h0     = transp * x;

            labelResult.Content = "Results: " + h0[0, 0].ToString();
        }
Пример #2
0
        private void Predict()
        {
            DataGridRow row = DataGridExtension.GetRow(dataGridPredict, 0);

            List <double> x = new List <double>();

            x.Add(1);
            for (int i = 0; i < dataGridPredict.Columns.Count; i++)
            {
                TextBlock cellContent = dataGridPredict.Columns[i].GetCellContent(row) as TextBlock;
                if (cellContent != null)
                {
                    x.Add(double.Parse(cellContent.Text, CultureInfo.InvariantCulture));
                }
            }

            if (x.Count != AttrCount)
            {
                throw new Exception("Entered incorrect values");
            }

            double result = h0(thetas, x);

            if (result >= 0.5)
            {
                labelResult.Content = "Result: 1 = Good quality of wine";
            }
            else
            {
                labelResult.Content = "Result: 0 = Bad quality of wine";
            }
        }