Ejemplo n.º 1
0
class TestMF(TestCase):
    mf_engine = mf.MF()
    test_data = mf.generate_test_data(100, 50, 1000)
    mf_engine.fit(test_data)

    def test_fit(self):
        print("testing fit method")
        TestMF.mf_engine.fit(TestMF.test_data)

    def test_predict(self):
        print("testing predict method")
        n = 1000
        pred_data = mf.generate_test_data(100, 50, n, indices_only=True)
        predictions = TestMF.mf_engine.predict(pred_data)
        self.assertTrue(len(predictions) == n)
        for i in predictions.tolist():
            self.assertTrue(type(i) is float)
            self.assertFalse(math.isnan(i))

    def test_cross_val(self):
        print("testing cross val method")
        val_data = mf.generate_test_data(100, 50, 1000)
        TestMF.mf_engine.mf_cross_validation(val_data)

    def test_factorq(self):
        print("testing factor-q")
        q = TestMF.mf_engine.q_factors()
        self.assertEqual(q.shape,
                         (TestMF.mf_engine.model.n, TestMF.mf_engine.model.k))

    def test_factorp(self):
        print("testing factor-p")
        p = TestMF.mf_engine.p_factors()
        self.assertEqual(p.shape,
                         (TestMF.mf_engine.model.m, TestMF.mf_engine.model.k))
Ejemplo n.º 2
0
 def test_predict(self):
     print("testing predict method")
     n = 1000
     pred_data = mf.generate_test_data(9000, 1000, n, indices_only=True)
     predictions = TestMF.mf_engine.mf_predict(pred_data)
     self.assertTrue(len(predictions) == n)
     for i in predictions.tolist():
         self.assertTrue(type(i) is float)
         self.assertFalse(math.isnan(i))
Ejemplo n.º 3
0
class TestMF(TestCase):
    mf_engine = mf.MF()
    test_data = mf.generate_test_data(9000, 1000, 25000)
    mf_engine.mf_fit(test_data)

    def test_fit(self):
        print("testing fit method")
        TestMF.mf_engine.mf_fit(TestMF.test_data)

    def test_predict(self):
        print("testing predict method")
        n = 1000
        pred_data = mf.generate_test_data(9000, 1000, n, indices_only=True)
        predictions = TestMF.mf_engine.mf_predict(pred_data)
        self.assertTrue(len(predictions) == n)
        for i in predictions.tolist():
            self.assertTrue(type(i) is float)
            self.assertFalse(math.isnan(i))

    def test_cross_val(self):
        print("testing cross val method")
        val_data = mf.generate_test_data(9000, 1000, 10000)
        TestMF.mf_engine.mf_cross_validation(val_data)
Ejemplo n.º 4
0
 def test_cross_val(self):
     print("testing cross val method")
     val_data = mf.generate_test_data(9000, 1000, 10000)
     TestMF.mf_engine.mf_cross_validation(val_data)