private void btnStochastic1_Click(object sender, EventArgs e) { var regression = new LogisticRegression(); double[,] sourceMatrix; double[,] inputs; double[] labels; GetData(out sourceMatrix, out inputs, out labels); _weight = regression.StochasticGradientAscent1(inputs.ToArray(), labels); var aaa = sourceMatrix.Submatrix(0, sourceMatrix.GetLength(0) - 1, 1, 3); CreateRegressPlot(graphInput, aaa, _weight); }
private double HorseColicTest() { double[,] sourceMatrix; double[,] inputs; double[] labels; GetData(dgvTest, out sourceMatrix, out inputs, out labels); var regression = new LogisticRegression(); _weight = regression.StochasticGradientAscent1(inputs.ToArray(), labels); var errorCount = 0; for (var i = 0; i < inputs.GetLength(0); i++) { var output = regression.Classify(inputs.GetRow(i), _weight); if (output != labels[i]) errorCount++; } var errorRate = (double)errorCount / inputs.GetLength(0); return errorRate; }
private void cmdTest_Click(object sender, EventArgs e) { var x1 = Convert.ToDouble(txtX1.Text); var x2 = Convert.ToDouble(txtX2.Text); var input = new[]{1, x1,x2}; var regression = new LogisticRegression(); var cls = regression.Classify(input, _weight); var s = cls == 0.0 ? "Blue" : "Green"; MessageBox.Show("Class = " + s); }