Iteration() public method

Perform a single training iteration.
public Iteration ( ) : void
return void
Esempio n. 1
0
        public void TestCluster()
        {
            var set = new BasicMLDataSet();

            int i;
            for (i = 0; i < Data.Length; i++)
            {
                set.Add(new BasicMLData(Data[i]));
            }

            var kmeans = new KMeansClustering(2, set);
            kmeans.Iteration();

            i = 1;
            foreach (IMLCluster cluster in kmeans.Clusters)
            {
                IMLDataSet ds = cluster.CreateDataSet();
                IMLDataPair pair;
                pair = ds[0];
                double t = pair.Input[0];

                for (int j = 0; j < ds.Count; j++)
                {
                    pair = ds[j];

                    for (j = 0; j < pair.Input.Count; j++)
                    {
                        if (t > 10)
                        {
                            Assert.IsTrue(pair.Input[j] > 10);
                        }
                        else
                        {
                            Assert.IsTrue(pair.Input[j] < 10);
                        }
                    }
                }

                i++;
            }
        }
Esempio n. 2
0
        public void TestCluster()
        {
            var set = new BasicMLDataSet();

            int i;
            for (i = 0; i < Data.Length; i++)
            {
                set.Add(new BasicMLData(Data[i]));
            }

            var kmeans = new KMeansClustering(2, set);
            kmeans.Iteration();

            i = 1;
            foreach (IMLCluster cluster in kmeans.Clusters)
            {
                IMLDataSet ds = cluster.CreateDataSet();
                IMLDataPair pair = BasicMLDataPair.CreatePair(ds.InputSize, ds.IdealSize);
                ds.GetRecord(0, pair);
                double t = pair.InputArray[0];

                for (int j = 0; j < ds.Count; j++)
                {
                    ds.GetRecord(j, pair);

                    for (j = 0; j < pair.InputArray.Length; j++)
                    {
                        if (t > 10)
                        {
                            Assert.IsTrue(pair.InputArray[j] > 10);
                        }
                        else
                        {
                            Assert.IsTrue(pair.InputArray[j] < 10);
                        }
                    }
                }

                i++;
            }
        }
Esempio n. 3
0
        /// <summary>
        ///     Process the file and cluster.
        /// </summary>
        /// <param name="outputFile">The output file.</param>
        /// <param name="clusters">The number of clusters.</param>
        /// <param name="theAnalyst">The analyst to use.</param>
        /// <param name="iterations">The number of iterations to use.</param>
        public void Process(FileInfo outputFile, int clusters,
                            EncogAnalyst theAnalyst, int iterations)
        {
            StreamWriter tw = PrepareOutputFile(outputFile);

            ResetStatus();

            var cluster = new KMeansClustering(clusters,
                                               _data);
            cluster.Iteration(iterations);

            int clusterNum = 0;

            foreach (IMLCluster cl  in  cluster.Clusters)
            {
                foreach (IMLData item  in  cl.Data)
                {
                    int clsIndex = item.Count;
                    var lr = new LoadedRow(Format, item, 1);
                    lr.Data[clsIndex] = "" + clusterNum;
                    WriteRow(tw, lr);
                }
                clusterNum++;
            }

            ReportDone(false);
            tw.Close();
        }
Esempio n. 4
0
 public void Process(FileInfo outputFile, int clusters, EncogAnalyst theAnalyst, int iterations)
 {
     KMeansClustering clustering;
     int num;
     int num2;
     IMLCluster[] clusterArray;
     int num3;
     StreamWriter tw = this.xf911a8958011bd6d(outputFile);
     goto Label_014D;
     Label_001F:
     if (num3 >= clusterArray.Length)
     {
         if ((((uint) num2) | 0x80000000) != 0)
         {
             if ((((uint) num) + ((uint) num)) <= uint.MaxValue)
             {
                 base.ReportDone(false);
                 tw.Close();
                 return;
             }
             goto Label_014D;
         }
         goto Label_00F7;
     }
     IMLCluster cluster = clusterArray[num3];
     Label_004F:
     using (IEnumerator<IMLData> enumerator = cluster.Data.GetEnumerator())
     {
         LoadedRow row2;
         goto Label_0090;
     Label_005E:
         row2.Data[num2] = num;
         if ((((uint) num3) & 0) != 0)
         {
             goto Label_00AD;
         }
         base.WriteRow(tw, row2);
     Label_0090:
         if (!enumerator.MoveNext())
         {
             goto Label_00D6;
         }
         IMLData current = enumerator.Current;
         ClusterRow row = (ClusterRow) current;
     Label_00AD:
         num2 = row.Input.Count - 1;
         row2 = row.Row;
         goto Label_005E;
     }
     Label_00D6:
     num++;
     num3++;
     if (((uint) num) < 0)
     {
         goto Label_004F;
     }
     goto Label_001F;
     Label_00F7:
     clustering = new KMeansClustering(clusters, this._x4a3f0a05c02f235f);
     if (((uint) num2) < 0)
     {
         goto Label_00F7;
     }
     clustering.Iteration(iterations);
     num = 0;
     clusterArray = clustering.Clusters;
     num3 = 0;
     goto Label_001F;
     Label_014D:
     base.ResetStatus();
     goto Label_00F7;
 }