예제 #1
0
        public void TestMultistepSingleValue()
        {
            _classifier = new CLAClassifier(new[] { 1, 2 });

            // Only should return one actual value bucket.
            Classification <double> result = null;
            int recordNum = 0;

            for (int i = 0; i < 10; i++, recordNum++)
            {
                result = Compute <double>(_classifier, recordNum, new[] { 1, 5 }, 0, 10);
            }

            Assert.IsTrue(Arrays.AreEqual(new double[] { 10.0 }, result.GetActualValues()));
            // Should have a probability of 100% for that bucket.
            Assert.IsTrue(Arrays.AreEqual(new double[] { 1.0 }, result.GetStats(1)));
            Assert.IsTrue(Arrays.AreEqual(new double[] { 1.0 }, result.GetStats(2)));
        }
예제 #2
0
        public void TestMultistepSingleValue()
        {
            var classifier = new SDRClassifier(new[] { 1, 2 });

            Classification <double> retVal = null;

            for (int i = 0; i < 10; i++)
            {
                retVal = _compute(classifier, i, new[] { 1, 5 }, 0, 10);
            }

            // Since overlap - should be previous with high likelihood
            double[] actValues = retVal.GetActualValues();

            Assert.AreEqual((double)actValues[0], 10);
            double[] resultDoubles1 = (double[])retVal.GetStats(1);
            double[] resultDoubles2 = (double[])retVal.GetStats(2);

            Assert.AreEqual(resultDoubles1[0], 1);
            Assert.AreEqual(resultDoubles2[0], 1);
        }
예제 #3
0
        private static Func <IInference, int, int> CreateDayOfWeekInferencePrintout(bool on)
        {
            int cycles = 1;

            return((IInference inf, int cellsPerColumn) =>
            {
                Classification <Object> result = inf.GetClassification("dayOfWeek");
                double day = MapToInputData((int[])inf.GetLayerInput());
                if (day == 1.0)
                {
                    if (on)
                    {
                        Console.WriteLine("\n=========================");
                        Console.WriteLine("CYCLE: " + cycles);
                    }
                    cycles++;
                }

                if (on)
                {
                    Console.WriteLine("RECORD_NUM: " + inf.GetRecordNum());
                    Console.WriteLine("ScalarEncoder Input = " + day);
                    Console.WriteLine("ScalarEncoder Output = " + Arrays.ToString(inf.GetEncoding()));
                    Console.WriteLine("SpatialPooler Output = " + Arrays.ToString(inf.GetFeedForwardActiveColumns()));

                    if (inf.GetPreviousPredictiveCells() != null)
                    {
                        Console.WriteLine("TemporalMemory Previous Prediction = " +
                                          Arrays.ToString(SDR.CellsAsColumnIndices(inf.GetPreviousPredictiveCells(), cellsPerColumn)));
                    }

                    Console.WriteLine("TemporalMemory Actives = " + Arrays.ToString(SDR.AsColumnIndices(inf.GetSdr(), cellsPerColumn)));

                    Console.Write("CLAClassifier prediction = " +
                                  result.GetMostProbableValue(1) + " --> " + result.GetMostProbableValue(1));

                    Console.WriteLine("  |  CLAClassifier 1 step prob = " + Arrays.ToString(result.GetStats(1)) + "\n");
                }
                return cycles;
            });
        }