示例#1
0
        void detects_anomalies_with_one_threshold_set()
        {
            act = () => anomalies = detector.DetectAnomalies(testData);

            context["when only upper threshold is set"] = () =>
            {
                before = () =>
                {
                    detector = new ThresholdDetector <double, int>(null, 5.0);
                };

                it["detects anomalies above the upper threshold"] = () =>
                {
                    anomalies.Should().Match(a => a.All(p => p.DataPoint.Value > 5.0));
                };
            };

            context["when only lower threshold is set"] = () =>
            {
                before = () =>
                {
                    detector = new ThresholdDetector <double, int>(0.0, null);
                };

                it["detects anomalies below the lower threshold"] = () =>
                {
                    anomalies.Should().Match(a => a.All(p => p.DataPoint.Value < 0.0));
                };
            };
        }
示例#2
0
        void detects_no_anomalies()
        {
            act = () => anomalies = detector.DetectAnomalies(testData);

            context["when all points are within the thresholds"] = () =>
            {
                before = () =>
                {
                    detector = new ThresholdDetector <double, int>(-20, 20);
                };

                it["detects no anomalies"] = () =>
                {
                    anomalies.Should().BeEmpty();
                };
            };
        }
示例#3
0
        void detects_anomalies_in_data()
        {
            act = () => anomalies = detector.DetectAnomalies(testData);

            context["when upper threshold is given"] = () =>
            {
                before = () =>
                {
                    detector = new ThresholdDetector <double, int>(upperThreshold: 5.0);
                };

                it["detects anomalies above the upper threshold"] = () =>
                {
                    anomalies.Should().HaveCount(1);
                    anomalies[0].DataPoint.Value.ShouldBeEquivalentTo(10.0);
                };
            };

            context["when lower threshold is given"] = () =>
            {
                before = () =>
                {
                    detector = new ThresholdDetector <double, int>(lowerThreshold: 0.0);
                };

                it["detects anomalies below the lower threshold"] = () =>
                {
                    anomalies.Should().HaveCount(1);
                    anomalies[0].DataPoint.Value.ShouldBeEquivalentTo(-3.0);
                };
            };

            context["when both thresholds are given"] = () =>
            {
                before = () =>
                {
                    detector = new ThresholdDetector <double, int>(0.0, 5.0);
                };

                it["detects anomalies outside the thresholds"] = () =>
                {
                    anomalies.Should().HaveCount(2);
                };
            };
        }