Esempio n. 1
0
        private void btn_reset_Click(object sender, EventArgs e)
        {
            timer1.Stop();
            //_numOfCodeVectors = System.Convert.ToInt32(nud_numOfCodeVectors.Value);
            get_parameters();
            _graphics.Clear(Color.White);
            _lvq = new LVQAlgorithm();
            _lvq.trainingData = _data;
            _lvq.testingData  = _data;
            _lvq.Initialize(_numOfCodeVectors);

            Drawing.DrawCodeVectors(_graphics, _lvq._w);

            Drawing.DrawData(_graphics, _data, _width, _height);
            pictureBox1.Image = _bitmap;
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Random random = new Random();
            string path   = "iris.txt";
            //string path = "diabetes.txt";
            //string path = "vote.txt";
            //string path = "iris2D.txt";
            int N = 10; //k - fold
            int M = 1;  //liczba wektorów kodujących
            List <List <Vector> > d        = new List <List <Vector> >();
            List <Vector>         _data    = DataFileReader.GetDataFromFile(path);
            List <Vector>         tempData = _data.ToList();
            int b = _data.Count() / N;

            for (int i = 0; i < N; i++)
            {
                d.Add(new List <Vector>());
                for (int j = 0; j < b; j++)
                {
                    int x = random.Next(tempData.Count);
                    d.Last().Add(tempData[x]);
                    tempData.RemoveAt(x);
                }
            }
            d.Last().AddRange(tempData);
            int num = 0;

            for (int i = 0; i < N; i++)
            {
                LVQAlgorithm _lvq = new LVQAlgorithm();
                _lvq.trainingData = makeTrainingSet(d, i);
                _lvq.testingData  = d[i];
                _lvq.Initialize(M);
                _lvq.Learn(100);
                num += _lvq.Test();
            }
            Console.WriteLine("Crossvalidation {0}-folds", N);
            Console.WriteLine("Number of Codebooks Vectors: {0}", M);
            Console.WriteLine("Number of Instances : {0}", _data.Count);
            Console.WriteLine("Correctly Classified Instances : {0}", num);
            Console.WriteLine("Incorrectly Classified Instances : {0}", _data.Count - num);
            Console.WriteLine("Accuracy: {0:F5}%", 100 * (double)num / _data.Count);
            Console.ReadKey();
        }
Esempio n. 3
0
        public Form1()
        {
            InitializeComponent();

            _bitmap           = Drawing.DrawBitmap(_height, _width);
            _graphics         = Graphics.FromImage(_bitmap);
            pictureBox1.Image = _bitmap;
            //string fileName = "lol.txt";
            string fileName = "iris2D.txt";

            _data = DataFileReader.GetDataFromFile(fileName);
            DataStandarizator.NormalizeData(_data);
            _lvq = new LVQAlgorithm();
            _lvq.trainingData = _data;
            _lvq.testingData  = _data;
            _lvq.Initialize(_numOfCodeVectors);
            Drawing.DrawData(_graphics, _data, _width, _height);
            Drawing.DrawCodeVectors(_graphics, _lvq._w);
        }