Esempio n. 1
0
 //Methods
 /// <summary>
 /// Adds a new member network and updates the cluster error statistics.
 /// </summary>
 /// <param name="newMemberNet">The new member network.</param>
 /// <param name="scopeID">The ID of a network's scope.</param>
 /// <param name="testData">The testing data bundle (unseen by the network to be added).</param>
 /// <param name="filters">The filters to be used to denormalize outputs.</param>
 public void AddMember(TNRNet newMemberNet, int scopeID, VectorBundle testData, FeatureFilterBase[] filters)
 {
     //Check the network output
     if (Output != newMemberNet.Output)
     {
         throw new ArgumentException("Inconsistent output type of the network to be added.", "newMemberNet");
     }
     //Check number of outputs consistency
     if (_memberNetCollection.Count > 0)
     {
         if (newMemberNet.Network.NumOfOutputValues != NumOfOutputs)
         {
             throw new ArgumentException("Number of outputs of the network differs from already clustered networks.", "newMemberNet");
         }
     }
     //Add member to inner collection
     _memberNetCollection.Add(newMemberNet);
     _memberNetScopeIDCollection.Add(scopeID);
     //Update cluster error statistics
     for (int sampleIdx = 0; sampleIdx < testData.OutputVectorCollection.Count; sampleIdx++)
     {
         double[] nrmComputedValues = newMemberNet.Network.Compute(testData.InputVectorCollection[sampleIdx]);
         for (int outIdx = 0; outIdx < nrmComputedValues.Length; outIdx++)
         {
             double naturalComputedValue = filters != null ? filters[outIdx].ApplyReverse(nrmComputedValues[outIdx]) : nrmComputedValues[outIdx];
             double naturalIdealValue    = filters != null ? filters[outIdx].ApplyReverse(testData.OutputVectorCollection[sampleIdx][outIdx]) : testData.OutputVectorCollection[sampleIdx][outIdx];
             ErrorStats.Update(nrmComputedValues[outIdx],
                               testData.OutputVectorCollection[sampleIdx][outIdx],
                               naturalComputedValue,
                               naturalIdealValue
                               );
         } //outIdx
     }     //sampleIdx
     return;
 }
Esempio n. 2
0
        private void CalculateErrorPercents(ErrorStats errors)
        {
            errors.SortedValues = new double[errors.Values.Length];
            Array.Copy(errors.Values, errors.SortedValues, errors.Values.Length);
            Array.Sort(errors.SortedValues);

            errors.Mean    = MathUtils.Mean(errors.Values);
            errors.AbsMean = MathUtils.Mean(MathUtils.Abs(errors.Values));
            errors.Std     = MathUtils.StandardDeviation(errors.Values, errors.Mean);

            errors.Minimum   = errors.SortedValues[0];
            errors.Percent25 = errors.SortedValues[errors.SortedValues.Length * 25 / 100];
            errors.Percent50 = errors.SortedValues[errors.SortedValues.Length * 50 / 100];
            errors.Percent75 = errors.SortedValues[errors.SortedValues.Length * 75 / 100];
            errors.Maximum   = errors.SortedValues[errors.SortedValues.Length - 1];
        }