public void Search_001()
        {
            var nnc = new PercentileKNearestNeighborCalculator(
                x: new Percentile(11),
                data: new Percentile[] {
                new Percentile(1),
                new Percentile(5),
                new Percentile(9),
                new Percentile(13),
                new Percentile(18),
                new Percentile(25)
            },
                k: 2
                );

            Maybe <List <KnnResult <Percentile> > > resultMaybe = nnc.Search();

            //Assert.IsNotNull(result);
            Assert.IsTrue(resultMaybe.HasValue);

            var result = resultMaybe.Value;

            Assert.AreEqual(new Percentile(9), result[0].Value);
            Assert.AreEqual(new Percentile(13), result[1].Value);
        }
Example #2
0
        public Foot Generate()
        {
            Percentile rndPct = _percentileGenerator.Generate();

            var calculator = new PercentileKNearestNeighborCalculator <Foot>(rndPct, _data);

            return(calculator.GetNearestNeighbours().Value[0].Value.Object);
        }
Example #3
0
        public PercentileGrowth GetForPercentile(Percentile percentile)
        {
            var calculator = new PercentileKNearestNeighborCalculator
                             (
                percentile,
                _growths.Select(pg => pg.Percentile).ToArray()
                             );

            Maybe <List <KnnResult <Percentile> > > resultList = calculator.Search();

            resultList.ValueOrThrow(new ApplicationException("No value returned"));

            KnnResult <Percentile> knnResult = resultList.Value[0];

            return(_growths[knnResult.Position.IndexValue]);
        }