Beispiel #1
0
        public void DrawSOM(TSOM SOM)
        {
            double max = 0;

            for (int i = 0; i < SOM.Count; i++)
            {
                double v = SOM[i].Val();
                if (v > max)
                {
                    max = v;
                }
            }

            Brush br;

            double L = g.Width;

            double dl = L / M;

            for (int i = 0; i < M; i++)
            {
                for (int j = 0; j < M; j++)
                {
                    br = GetColor(SOM.Net[i, j].Val() / max);

                    Ellipse O = new Ellipse();
                    O.Stroke = br;
                    O.Fill   = br;
                    O.Width  = dl;
                    O.Height = dl;
                    O.Margin = new Thickness(i * dl, j * dl, 0, 0);
                    g.Children.Add(O);
                }
            }
        }
Beispiel #2
0
        private void cmBuild(object sender, RoutedEventArgs e)
        {
            g.Children.Clear();

            Filer = new TFiler("t.txt");

            N = Filer[0].N;

            Filer.Normalize();

            Map = new TMap(g, M);

            SOM = new TSOM(Map, M, N);

            XX = new TX[Filer.Count];

            for (int i = 0; i < Filer.Count; i++)
            {
                XX[i] = Filer[i];
            }

            Learning = new TLearning(SOM, XX);

            //Map.DrawSOM(SOM);

            Map.DrawData(SOM, XX);
        }
Beispiel #3
0
        public MainWindow()
        {
            InitializeComponent();

            Map = null;
            SOM = null;
        }
Beispiel #4
0
        public TLearning(TSOM SOM, TX[] XX)
        {
            this.SOM = SOM;
            N        = SOM.N;
            this.XX  = XX;

            rnd = new Random();

            DoLearning();
        }
Beispiel #5
0
        public void DrawData(TSOM SOM, TX[] XX)
        {
            double[,] Data = new double[M, M];

            for (int i = 0; i < M; i++)
            {
                for (int j = 0; j < M; j++)
                {
                    Data[i, j] = 0;
                }
            }

            double max = 0;

            for (int k = 0; k < XX.Count(); k++)
            {
                double min = double.MaxValue;
                int    ind = -1;

                for (int n = 0; n < SOM.Count; n++)
                {
                    double d = SOM[n].R(XX[k].x);

                    if (d < min)
                    {
                        min = d;
                        ind = n;
                    }
                }

                int[] ij = SOM.Get_ij(ind);
                Data[ij[0], ij[1]] += 1;

                if (Data[ij[0], ij[1]] > max)
                {
                    max = Data[ij[0], ij[1]];
                }
            }

            Brush br;

            double L = g.Width;

            double dl = L / M;

            for (int i = 0; i < M; i++)
            {
                for (int j = 0; j < M; j++)
                {
                    if (Data[i, j] == 0)
                    {
                        continue;
                    }

                    br = Brushes.White; //GetColor(Data[i, j] / max);

                    Ellipse O = new Ellipse();
                    O.Stroke = br;
                    O.Fill   = br;
                    O.Width  = dl;
                    O.Height = dl;
                    O.Margin = new Thickness(i * dl, j * dl, 0, 0);
                    g.Children.Add(O);
                }
            }
        }