Пример #1
0
                /// Tests that the
                /// <see cref="NumericalBin.
                /// GetNumericalBins(DoubleMatrix, DoubleMatrix)"/>
                /// method terminates successfully as expected when
                /// its parameters are valid and a final cut point exists.
                /// </summary>
                public static void FinalCutPointExists()
                {
                    var numericalData = DoubleMatrix.Dense(5, 1,
                                                           new double[5] {
                        -1, -1, 1, 1, 2
                    });
                    var targetData = DoubleMatrix.Dense(5, 1,
                                                        new double[5] {
                        10, 20, 10, 10, 10
                    });
                    var bins = NumericalBin.GetNumericalBins(
                        numericalData,
                        targetData);

                    NumericalBinAssert.IsStateAsExpected(
                        target: bins[0],
                        expectedFirstPosition: 0,
                        expectedLastPosition: 1,
                        expectedFirstValue: -1,
                        expectedLastValue: -1,
                        expectedTargetFrequencyDistribution:
                        new Dictionary <double, int>(2)
                    {
                        { 10, 1 }, { 20, 1 }
                    });

                    NumericalBinAssert.IsStateAsExpected(
                        target: bins[1],
                        expectedFirstPosition: 2,
                        expectedLastPosition: 3,
                        expectedFirstValue: 1,
                        expectedLastValue: 1,
                        expectedTargetFrequencyDistribution:
                        new Dictionary <double, int>(1)
                    {
                        { 10, 2 }, { 20, 0 }
                    });

                    NumericalBinAssert.IsStateAsExpected(
                        target: bins[2],
                        expectedFirstPosition: 4,
                        expectedLastPosition: 4,
                        expectedFirstValue: 2,
                        expectedLastValue: 2,
                        expectedTargetFrequencyDistribution:
                        new Dictionary <double, int>(1)
                    {
                        { 10, 1 }, { 20, 0 }
                    });
                }
Пример #2
0
                /// Tests that the
                /// <see cref="NumericalBin.
                /// GetNumericalBins(DoubleMatrix, DoubleMatrix)"/>
                /// method terminates successfully as expected when
                /// its parameters are valid and the data length is 1.
                /// </summary>
                public static void DataLengthIsOne()
                {
                    var numericalData = DoubleMatrix.Dense(1, 1, -1);
                    var targetData    = DoubleMatrix.Dense(1, 1, 10);
                    var bins          = NumericalBin.GetNumericalBins(
                        numericalData,
                        targetData);

                    NumericalBinAssert.IsStateAsExpected(
                        target: bins[0],
                        expectedFirstPosition: 0,
                        expectedLastPosition: 0,
                        expectedFirstValue: -1,
                        expectedLastValue: -1,
                        expectedTargetFrequencyDistribution:
                        new Dictionary <double, int>(1)
                    {
                        { 10, 1 }
                    });
                }