Пример #1
0
        private void m_RR8Classify_Click(object sender, RoutedEventArgs e)
        {
            var    result = m_ReutersR8Algorithm.Predict(m_RR8Input.Text);
            string text;

            switch (result.Value)
            {
            case 0: text = "Acquisition"; break;

            case 1: text = "Crude"; break;

            case 2: text = "Earnings and Investments"; break;

            case 3: text = "Grain"; break;

            case 4: text = "Interest Rates"; break;

            case 5: text = "Money"; break;

            case 6: text = "Ship"; break;

            case 7: text = "Trade"; break;

            default: text = "...unknown..."; break;
            }

            m_RR8Result.Text = text;
        }
Пример #2
0
        private void m_SpamClassify_Click(object sender, RoutedEventArgs e)
        {
            var text   = m_SpamInput.Text;
            var result = m_SpamAlgorithm.Predict(text);

            m_SpamResult.Text = (result.Value == 0) ? "Spam" : "Not spam";
        }
Пример #3
0
        private void m_N20Classify_Click(object sender, RoutedEventArgs e)
        {
            var    result = m_Newsgroups20Algorithm.Predict(m_N20Input.Text);
            string text;

            switch (result.Value)
            {
            case 0:  text = "Religion > Atheism"; break;

            case 1:  text = "Computers > Graphics"; break;

            case 2:  text = "Computers > MS Windows OS"; break;

            case 3:  text = "Computers > IBM Hardware"; break;

            case 4:  text = "Computers > Mac Hardware"; break;

            case 5:  text = "Computers > Windows X"; break;

            case 6:  text = "For Sale"; break;

            case 7:  text = "Autos"; break;

            case 8:  text = "Motorcycles"; break;

            case 9:  text = "Sport > Baseball"; break;

            case 10: text = "Sport > Hockey"; break;

            case 11: text = "Science > Cryptography"; break;

            case 12: text = "Science > Electronics"; break;

            case 13: text = "Science > Medicine"; break;

            case 14: text = "Science > Space"; break;

            case 15: text = "Religion > Christian"; break;

            case 16: text = "Politics > Guns"; break;

            case 17: text = "Politics > Mideast"; break;

            case 18: text = "Politics > Misc"; break;

            case 19: text = "Religion > Misc"; break;

            default: text = "...unknown..."; break;
            }

            m_N20Result.Text = text;
        }
Пример #4
0
        private void doCalc(ClassificationAlgorithmBase <double[]> algorithm, StreamWriter writer)
        {
            for (var k = 0; k < Math.Max(m_XCnt, m_YCnt); k++)
            {
                var px = (k < m_XCnt) ? getProjPoint(k, 0)[0].ToString(CultureInfo.InvariantCulture) : string.Empty;
                var py = (k < m_YCnt) ? getProjPoint(0, k)[1].ToString(CultureInfo.InvariantCulture) : string.Empty;
                var pd = string.Empty;
                if (k < m_YCnt)
                {
                    var data = new double[m_XCnt];
                    for (int i = 0; i < m_XCnt; i++)
                    {
                        var point = getPoint(i, k);
                        var cls   = algorithm.Predict(point);
                        data[i] = cls.Value;
                    }
                    pd = string.Join(COMMA, data);
                }

                writer.WriteLine("{0},{1},{2}", px, py, pd);
            }
        }