Пример #1
0
 def setUp(self):
     self.le = LogisticEnsemble(models=[IdModel()])
     inp = [{
         "user": 10,
         "item": 100
     }, {
         "user": 10,
         "item": 110
     }, {
         "user": 12,
         "item": 120
     }]
     self.df = pd.DataFrame(inp)
Пример #2
0
class LogisticTest(unittest.TestCase):
    def setUp(self):
        self.le = LogisticEnsemble(models=[IdModel()])
        inp = [{
            "user": 10,
            "item": 100
        }, {
            "user": 10,
            "item": 110
        }, {
            "user": 12,
            "item": 120
        }]
        self.df = pd.DataFrame(inp)

    def test_construct_features(self):

        self.le._prepare_feature_extraction(self.df)
        self.assertEqual(self.le._user_count, {10: 2, 12: 1})

    def test_extract_features(self):
        self.le._prepare_feature_extraction(self.df)
        features = self.le._extract_features(10, 5)
        self.assertEqual(features, ([2, 5], 1))

    def test_prepare_data(self):
        X, Y = self.le.prepare_data(self.df)
        self.assertEqual(len(X), 6)
        self.assertEqual(len(Y), 6)

    def test_fit(self):
        self.le.fit(self.df)
        self.assertIsNotNone(self.le.model)

    def test_predict(self):
        self.le.fit(self.df)
        self.assertIsInstance(self.le.get_score(10, 110), float)
Пример #3
0
class LogisticTest(unittest.TestCase):

    def setUp(self):
        self.le = LogisticEnsemble(models=[IdModel()])
        inp = [{"user": 10, "item": 100}, {"user": 10,"item": 110},
               {"user": 12, "item": 120}]
        self.df = pd.DataFrame(inp)

    def test_construct_features(self):

        self.le._prepare_feature_extraction(self.df)
        self.assertEqual(self.le._user_count, {10: 2, 12: 1})

    def test_extract_features(self):
        self.le._prepare_feature_extraction(self.df)
        features = self.le._extract_features(10, 5)
        self.assertEqual(features, ([2, 5], 1))

    def test_prepare_data(self):
        X, Y = self.le.prepare_data(self.df)
        self.assertEqual(len(X), 6)
        self.assertEqual(len(Y), 6)

    def test_fit(self):
        self.le.fit(self.df)
        self.assertIsNotNone(self.le.model)

    def test_predict(self):
        self.le.fit(self.df)
        self.assertIsInstance(self.le.get_score(10, 110), float)
Пример #4
0
 def setUp(self):
     self.le = LogisticEnsemble(models=[IdModel()])
     inp = [{"user": 10, "item": 100}, {"user": 10,"item": 110},
            {"user": 12, "item": 120}]
     self.df = pd.DataFrame(inp)
Пример #5
0
 def setUp(self):
     self.le = LogisticEnsemble(models=[IdModel()])
     inp = [{'user': 10, 'item': 100}, {'user': 10,'item': 110},
            {'user': 12,'item': 120}]
     self.df = pd.DataFrame(inp)