public void GetSimilar_Pivoted_PearsonSimilarity()
        {
            var data = TransformData(PCI_Data);

            var engine = new RecommendationEngine();
            var pivoted = engine.Pivot(data);
            var target = pivoted.Single(x => x.Owner == "Superman Returns");
            var result = engine.GetSimilar(target, pivoted, PearsonCorrelation.Calculate);

            Assert.That(result[0].Key, Is.EqualTo("You, Me and Dupree"));
            Assert.That(result[0].Score, Is.EqualTo(0.657).Within(0.001));

            Assert.That(result[1].Key, Is.EqualTo("Lady in the Water"));
            Assert.That(result[1].Score, Is.EqualTo(0.487).Within(0.001));

            Assert.That(result[2].Key, Is.EqualTo("Snakes on a Plane"));
            Assert.That(result[2].Score, Is.EqualTo(0.111).Within(0.001));

            Assert.That(result[3].Key, Is.EqualTo("The Night Listener"));
            Assert.That(result[3].Score, Is.EqualTo(-0.179).Within(0.001));

            Assert.That(result[4].Key, Is.EqualTo("Just My Luck"));
            Assert.That(result[4].Score, Is.EqualTo(-0.422).Within(0.001));
        }
        public void GetSimilar_EuclideanDistance()
        {
            var transformedData = TransformData(PCI_Data);
            var toby = TransformUser(PCI_Data, "Lisa Rose");

            var engine = new RecommendationEngine();
            var similarUsers = engine.GetSimilar(toby, transformedData, EuclideanDistanceTests.CalculateBroken);

            Assert.That(similarUsers[0].Key, Is.EqualTo("Michael Phillips"));
            Assert.That(similarUsers[0].Score, Is.EqualTo(0.4444444444444444).Within(Delta), "Score for 'Michael Phillips'");

            Assert.That(similarUsers[1].Key, Is.EqualTo("Mick LaSalle"));
            Assert.That(similarUsers[1].Score, Is.EqualTo(0.3333333333333333).Within(Delta), "Score for 'Mick LaSelle'");

            Assert.That(similarUsers[2].Key, Is.EqualTo("Claudia Puig"));
            Assert.That(similarUsers[2].Score, Is.EqualTo(0.2857142857142857).Within(Delta), "Score for 'Claudia Puig'");

            Assert.That(similarUsers[3].Key, Is.EqualTo("Toby"));
            Assert.That(similarUsers[3].Score, Is.EqualTo(0.2222222222222222).Within(Delta), "Score for 'Toby'");

            Assert.That(similarUsers[4].Key, Is.EqualTo("Jack Matthews"));
            Assert.That(similarUsers[4].Score, Is.EqualTo(0.21052631578947367).Within(Delta), "Score for 'Jack Matthews'");

            Assert.That(similarUsers[5].Key, Is.EqualTo("Gene Seymour"));
            Assert.That(similarUsers[5].Score, Is.EqualTo(0.14814814814814814).Within(Delta), "Score for 'Gene Seymour'");
        }
        public void GetSimilar_PearsonSimilarity()
        {
            var transformedData = TransformData(PCI_Data);
            var toby = TransformUser(PCI_Data, "Toby");

            var engine = new RecommendationEngine();
            var similarUsers = engine.GetSimilar(toby, transformedData, PearsonCorrelation.Calculate);
            DebugPrint(similarUsers);

            Assert.That(similarUsers[0].Key, Is.EqualTo("Lisa Rose"));
            Assert.That(similarUsers[0].Score, Is.EqualTo(0.99124070716192991).Within(Delta), "Score for 'Lisa Rose'");

            Assert.That(similarUsers[1].Key, Is.EqualTo("Mick LaSalle"));
            Assert.That(similarUsers[1].Score, Is.EqualTo(0.92447345164190486).Within(Delta), "Score for 'Mick LaSelle'");

            Assert.That(similarUsers[2].Key, Is.EqualTo("Claudia Puig"));
            Assert.That(similarUsers[2].Score, Is.EqualTo(0.89340514744156476).Within(Delta), "Score for 'Claudia Puig'");
        }