public void ReturnTrueIfFirstVectorIsKnown()
        {
            var bcmModel  = new BcmModel();
            var threshold = 2;

            bcmModel.Teach(_firstVector);
            bcmModel.Teach(_secondVector);

            bcmModel.Test(_firstVector, threshold).Should().BeTrue();
        }
        public void SecondTrainedVectorWithOtherLengthShouldThrowException()
        {
            var bcmModel = new BcmModel();
            var vectorWithOtherLength = Vector <float> .Build.Dense(8);

            bcmModel.Teach(_firstVector);

            Action trainingWithDifferentLengths = () => bcmModel.Teach(vectorWithOtherLength);

            trainingWithDifferentLengths.ShouldThrow <ArgumentException>();
        }
        public void ReturnFalseIfVectorIsNotKnown()
        {
            var bcmModel      = new BcmModel();
            var threshold     = 2;
            var unknownVector = Vector <float> .Build.DenseOfArray(new[] { 1f, 1, 1, 1, 0, 0 });

            bcmModel.Teach(_firstVector);
            bcmModel.Teach(_secondVector);

            bcmModel.Test(unknownVector, threshold).Should().BeFalse();
        }
        public void TrainShouldThrowExceptionIfMatrixAlreadyKnowsTwoVectors()
        {
            var bcmModel    = new BcmModel();
            var thirdVector = Vector <float> .Build.Dense(6);

            bcmModel.Teach(_firstVector);
            bcmModel.Teach(_secondVector);

            Action trainingWithKnownVector = () => bcmModel.Teach(thirdVector);

            trainingWithKnownVector.ShouldThrow <InvalidOperationException>();
        }
        public void TestMethodShouldThrowExceptionIfVectorHaveDifferentLength()
        {
            var bcmModel              = new BcmModel();
            var threshold             = 2;
            var vectorWithOtherLength = Vector <float> .Build.Dense(8);

            bcmModel.Teach(_firstVector);
            bcmModel.Teach(_secondVector);

            Action testingWithDifferentLengths = () => bcmModel.Test(vectorWithOtherLength, threshold);

            testingWithDifferentLengths.ShouldThrow <ArgumentException>();
        }
        public void FirstTrainedVectorShouldGiveMatrixSize()
        {
            var bcmModel = new BcmModel();

            bcmModel.Teach(_firstVector);

            bcmModel.CorrelationMatrix.ColumnCount.ShouldBeEquivalentTo(6);
        }
        public void TrainShouldThrowExceptionIfVectorValuesAreNotEqualZeroOrOne()
        {
            var            bcmModel            = new BcmModel();
            Vector <float> vectorWithBadValues = Vector <float> .Build.DenseOfArray(new[] { 1f, 1, 4, 0, 0, 0 });

            Action trainingWithBadValues = () => bcmModel.Teach(vectorWithBadValues);

            trainingWithBadValues.ShouldThrow <ArgumentException>();
        }
        public void SecondTrainedVectorShouldGiveRightMatrix()
        {
            var bcmModel      = new BcmModel();
            var correctMatrix = Matrix <float> .Build.DenseOfArray(new[, ]
            {
                { 1f, 1, 0, 0, 0, 0 },
                { 1, 1, 0, 0, 0, 1 },
                { 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0 },
                { 0, 1, 0, 0, 0, 1 }
            });

            bcmModel.Teach(_firstVector);
            bcmModel.Teach(_secondVector);

            bcmModel.CorrelationMatrix.ShouldBeEquivalentTo(correctMatrix);
        }