public IEmergingPattern Clone()
        {
            EmergingPattern result = new EmergingPattern(Model, ClassFeature, ClassValue, Items)
            {
                Supports = (double[])Supports.Clone(),
                Counts   = (double[])Counts.Clone(),
            };

            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Formats the contents of the Histogram into a simple acsii stem-leaf
        /// diagram.
        /// </summary>
        /// <remarks>If the bin boundaries are b0, b1, b2,...,bn-1, and the
        /// counts for these bins are c1, c2,...,cn, respectively,
        /// then the this method returns a string with the following
        /// format:
        /// Number SmallerCount:   ***number SmallerCount
        /// [b0,b1):     *****c1
        /// [b1,b2):     **********c2
        /// [b2,b3):     ***************c3
        /// .
        /// .
        /// .
        /// [bn-2,bn-1]: *****cn
        /// Number LargerCount : *****number LargerCount.
        /// Where the number of '*'s is for a particular bin is equal to
        /// the count for that bin minus one.</remarks>
        /// <returns>Fomatted string.</returns>
        public string StemLeaf(int maxMark)
        {
            var buff = new StringBuilder();

            if (SmallerCount > 0)
            {
                buff.AppendFormat("Number of SmallerCount: {0}", SmallerCount).AppendLine();
            }

            var sortedCount = (int[])Counts.Clone();

            Array.Sort(sortedCount);

            double scale;

            if (maxMark > 0)
            {
                scale = Math.Max(maxMark, 10) / (double)sortedCount[Counts.Length - 1];
            }
            else
            {
                scale = 1.0;
            }

            for (int i = 0; i < Counts.Length; i++)
            {
                char closing = (i == Counts.Length - 1) ? ']' : ')';
                buff.AppendFormat("[{0}, {1}{2}: {3}:{4}",
                                  BinBoundaries[i].ToString(FloatNumberFormat),
                                  BinBoundaries[i + 1].ToString(FloatNumberFormat),
                                  closing,
                                  "*".Replicate((int)(Counts[i] * scale)),
                                  Counts[i]);
                buff.AppendLine();
            }

            if (LargerCount > 0)
            {
                buff.AppendFormat("Number of LargerCount: {0}", LargerCount).AppendLine();
            }

            return(buff.ToString());
        }