Used to produce an array of activations to classify data into groups. This class is provided the number of groups, as well as the range that the activations should fall into.
        public static void Evaluate(FileOps fileOps)
        {
            var network = (BasicNetwork) EncogDirectoryPersistence.LoadObject(fileOps.TrainedNeuralNetworkFile);
            var analyst = new EncogAnalyst();
            analyst.Load(fileOps.AnalystFile);
            var evaluationSet = EncogUtility.LoadCSV2Memory(fileOps.NormalisedEvaluationFile.ToString(),
                network.InputCount, network.OutputCount, true, CSVFormat.English, false);
            var iteration = 0;
            var hitCount = 0;
            foreach (var evaluation in evaluationSet)
            {
                iteration++;
                var output = network.Compute(evaluation.Input);

                var sepalL = analyst.Script.Normalize.NormalizedFields[0].DeNormalize(evaluation.Input[0]);
                var sepalW = analyst.Script.Normalize.NormalizedFields[0].DeNormalize(evaluation.Input[1]);
                var petalL = analyst.Script.Normalize.NormalizedFields[0].DeNormalize(evaluation.Input[2]);
                var petalW = analyst.Script.Normalize.NormalizedFields[0].DeNormalize(evaluation.Input[3]);

                var classCount = analyst.Script.Normalize.NormalizedFields[4].Classes.Count;

                var normalisationHigh = analyst.Script.Normalize.NormalizedFields[4].NormalizedHigh;
                var normalisationLow = analyst.Script.Normalize.NormalizedFields[4].NormalizedLow;

                var eq = new Equilateral(classCount, normalisationHigh, normalisationLow);
                var predictedClassInt = eq.Decode(output);
                var predictedClass = analyst.Script.Normalize.NormalizedFields[4].Classes[predictedClassInt].Name;
                var idealClassInt = eq.Decode(evaluation.Ideal);
                var idealClass = analyst.Script.Normalize.NormalizedFields[4].Classes[idealClassInt].Name;

                Console.WriteLine("Predicted: {0} Ideal: {1}",predictedClass,idealClass);
                if (predictedClass == idealClass)
                {
                    hitCount++;
                }

            }
            Console.WriteLine("Total Test Count:{0}",iteration);
            Console.WriteLine("Total Correct Predictions: {0}",hitCount);
            Console.WriteLine("Success rate: {0}%", (((float)hitCount/(float)iteration)*100f));
            Console.ReadKey();
        }
 public int DenormalizeYear(double[] days, int MaxYear)
 {
     var eq = new Equilateral(MaxYear, -1, 1);
     return eq.Decode(days);
 }
 public int DenormalizeSeconds(double[] seconds)
 {
     var eq = new Equilateral(60, -1, 1);
     return eq.Decode(seconds);
 }
 public int DenormalizeMonth(double[] montharry)
 {
     var eq = new Equilateral(12, -1, 1);
     return eq.Decode(montharry);
 }
 public int DenormalizeHour(double[] hour)
 {
     var eq = new Equilateral(24, -1, 1);
     return eq.Decode(hour);
 }
示例#6
0
 public void Init()
 {
     int num;
     if (this._xab8fe3cd8c5556fb == NormalizationAction.Equilateral)
     {
         goto Label_0063;
     }
     Label_000E:
     num = 0;
     while (num < this._x8affa5274961ba3a.Count)
     {
         this._xba38fdafb6633fdf[this._x8affa5274961ba3a[num].Name] = this._x8affa5274961ba3a[num].Index;
         num++;
     }
     if (((uint) num) >= 0)
     {
         return;
     }
     Label_0063:
     if (this._x8affa5274961ba3a.Count < 3)
     {
         throw new QuantError("There must be at least three classes to make use of equilateral normalization.");
     }
     do
     {
         this._x8959a01885d5f522 = new Equilateral(this._x8affa5274961ba3a.Count, this._x891507b50bbab0f9, this._x136bfff0efb12047);
     }
     while (0 != 0);
     goto Label_000E;
 }
        /// <summary>
        /// Init any internal structures.
        /// </summary>
        ///
        public void Init()
        {
            if (_action == NormalizationAction.Equilateral)
            {
                if (_classes.Count < Equilateral.MinEq)
                {
                    throw new QuantError("There must be at least three classes "
                                         + "to make use of equilateral normalization.");
                }

                _eq = new Equilateral(_classes.Count, _normalizedHigh,
                                     _normalizedLow);
            }

            // build lookup map
            foreach (ClassItem t in _classes)
            {
                _lookup[t.Name] = t.Index;
            }
        }
 public double[] NormalizeMonth(int month)
 {
     var eq = new Equilateral(12, -1, 1);
     return eq.Encode(month);
 }
 public double[] NormalizeYear(int year)
 {
     var eq = new Equilateral(2011, -1, 1);
     return eq.Encode(year);
 }
        /// <summary>
        /// Init any internal structures.
        /// </summary>
        ///
        public void Init()
        {
            if (_action == NormalizationAction.Equilateral)
            {
                if (_classes.Count < MinEqClasses)
                {
                    throw new QuantError(
                        "There must be at least three classes to make "
                        + "use of equilateral normalization.");
                }

                _eq = new Equilateral(_classes.Count, _normalizedHigh,
                                      _normalizedLow);
            }

            // build lookup map
            for (int i = 0; i < _classes.Count; i++)
            {
                _lookup[_classes[i].Name] = _classes[i].Index;
            }
        }
        /// <summary>
        /// Determine which item's index is the value.
        /// </summary>
        public override void RowInit()
        {
            for (int i = 0; i < this.items.Count; i++)
            {
                NominalItem item = this.items[i];
                if (item.IsInRange())
                {
                    this.currentValue = i;
                    break;
                }
            }

            if (this.equilateral == null)
            {
                this.equilateral = new Equilateral(this.items.Count, this.high,
                        this.low);
            }
        }
示例#12
0
 public override void RowInit()
 {
     int num = 0;
     goto Label_002E;
     Label_0007:
     if (this._equilateral == null)
     {
         this._equilateral = new Encog.MathUtil.Equilateral(this._items.Count, this._high, this._low);
         goto Label_0060;
     }
     return;
     Label_002E:
     while (num < this._items.Count)
     {
         NominalItem item = this._items[num];
         if (item.IsInRange())
         {
             this._currentValue = num;
             if ((((uint) num) + ((uint) num)) <= uint.MaxValue)
             {
                 break;
             }
             goto Label_0060;
         }
         num++;
     }
     goto Label_0007;
     Label_0060:
     if ((((uint) num) <= uint.MaxValue) && ((((uint) num) | 0x7fffffff) != 0))
     {
         if (((uint) num) >= 0)
         {
             return;
         }
         goto Label_002E;
     }
     goto Label_0007;
 }
        public void TestClassification()
        {
            ClearClassPoints();
            TestingErrorValue = _network.CalculateError(TestingSet);

            var eq = new Equilateral(TrainingSet.IdealSize+1, 1, -1);
            foreach (var item in TrainingSet)
            {
                if (NormalizationType == NormalizationAction.OneOf)
                    ClassPoints[_network.Classify(item.Input)].Add(new Tuple<double, double>(item.Input[0], item.Input[1]));
                else
                {
                    var computedClass = new double[TrainingSet.IdealSize];
                    _network.Compute(item.Input).CopyTo(computedClass, 0, TrainingSet.IdealSize);
                    ClassPoints[eq.GetSmallestDistance(computedClass)].Add(new Tuple<double, double>(item.Input[0], item.Input[1]));
                }
            }
        }
示例#14
0
        public void TestDateNormalizeDaysEncode()
        {
            var eq = new Equilateral(DateTime.DaysInMonth(2012, 1), -1, 1);
            var encoded = eq.Encode(15);
            StringBuilder b = new StringBuilder(encoded.Length);
            for (int i = 0; i < encoded.Length; i++)
            {
                if (i < encoded.Length - 1)
                    b.Append(encoded[i] + ",");
                else b.Append(encoded[i]);
            }
            Console.WriteLine("Encoded 15 to Equilaterable " + b.ToString());
            Assert.IsNotNull(encoded, "Encoded is not null");
            Assert.IsTrue(encoded[14].ToString() == "-0.984250984251476");
            //Now we get the day back..

            int res = eq.Decode(encoded);
            Console.WriteLine("Result decode == " + res);
            Assert.AreEqual(15, res, "Decoded back to 15");
        }
示例#15
0
 public void Init()
 {
     if (this._xab8fe3cd8c5556fb == NormalizationAction.Equilateral)
     {
         if (this._x8affa5274961ba3a.Count < 3)
         {
             throw new QuantError("There must be at least three classes to make use of equilateral normalization.");
         }
         this._x8959a01885d5f522 = new Equilateral(this._x8affa5274961ba3a.Count, this._x891507b50bbab0f9, this._x136bfff0efb12047);
     }
     foreach (ClassItem item in this._x8affa5274961ba3a)
     {
         this._xba38fdafb6633fdf[item.Name] = item.Index;
     }
 }
 public double[] NormalizeDays(int days)
 {
     var eq = new Equilateral(31, -1, 1);
     return eq.Encode(days);
 }
 public double[] NormalizeHour(int hour)
 {
     var eq = new Equilateral(24, -1, 1);
     return eq.Encode(hour);
 }
 public double[] NormalizeYear(int hour, int MaxYear)
 {
     var eq = new Equilateral(MaxYear, -1, 1);
     return eq.Encode(hour);
 }
 public double[] NormalizeSeconds(int Seconds)
 {
     var eq = new Equilateral(60, -1, 1);
     return eq.Encode(Seconds);
 }
 public static int DenormalizeYear(double[] year)
 {
     var eq = new Equilateral(2011, -1, 1);
     return eq.Decode(year);
 }
        /// <summary>
        /// Determine which item's index is the value.
        /// </summary>
        public override void RowInit()
        {
            for (int i = 0; i < _items.Count; i++)
            {
                NominalItem item = _items[i];
                if (item.IsInRange())
                {
                    _currentValue = i;
                    break;
                }
            }

            if (_equilateral == null)
            {
                _equilateral = new Equilateral(_items.Count, _high,
                                              _low);
            }
        }
 public int DenormalizeDays(double[] days)
 {
     var eq = new Equilateral(31, -1, 1);
     return eq.Decode(days);
 }