예제 #1
0
        public void TestGetMostProbableValue()
        {
            string mon = "Monday";
            string tue = "Tuesday";
            string wed = "Wednesday";

            double monVal = 0.01d;
            double tueVal = 0.80d;
            double wedVal = 0.30d;

            Classification <string> result = new Classification <string>();

            result.SetActualValues(new[] { mon, tue, wed });
            result.SetStats(1, new[] { monVal, tueVal, wedVal });
            Assert.IsTrue(result.GetMostProbableValue(1).Equals(tue));
            Assert.IsNull(result.GetMostProbableValue(2));

            double monVal2 = 0.30d;
            double tueVal2 = 0.01d;
            double wedVal2 = 0.29d;

            result.SetStats(3, new[] { monVal2, tueVal2, wedVal2 });
            Assert.IsTrue(result.GetMostProbableValue(3).Equals(mon));
            Assert.IsNull(result.GetMostProbableValue(2));
        }
예제 #2
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;
            });
        }
예제 #3
0
        public void TestCopy()
        {
            string mon = "Monday";
            string tue = "Tuesday";
            string wed = "Wednesday";

            double monVal = 0.01d;
            double tueVal = 0.80d;
            double wedVal = 0.30d;

            Classification <string> result = new Classification <string>();

            result.SetActualValues(new[] { mon, tue, wed });
            result.SetStats(1, new[] { monVal, tueVal, wedVal });
            Assert.IsTrue(result.GetMostProbableValue(1).Equals(tue));
            Assert.IsNull(result.GetMostProbableValue(2));

            Classification <string> result2 = result.Copy();

            Assert.AreEqual(result, result2);

            result2.SetStats(1, new[] { monVal, tueVal, 0.5d });
            Assert.AreNotEqual(result, result2);
        }