Пример #1
0
    def test_rmse(self):
        eval = Evaluator()

        model = ConstantModel(constant=3.0)
        testing = pd.DataFrame([{'user':10, 'item':100, 'rating':3},
                                {'user':10,'item':110,'rating':1},
                                {'user':12,'item':100,'rating':4},
        ])
        rmse = eval.evaluate_model_rmse(model, testing)
        self.assertEqual(sqrt((0+4+1)/3.0), rmse)
        eval.close()
Пример #2
0
    sep="::", header=None, names=['user', 'item', 'rating', 'date', 'title'])
print df.head()

#tell me what models we want to evaluate
models = [
            RandomModel(),
            PopularityOkapi(host='54.72.18.118',
                            username='******',
                            #okapi_jar_dir='/Users/linas/devel/okapi/target/',
                            #okapi_jar_base_name='okapi-0.3.2-SNAPSHOT-jar-with-dependencies.jar',
                            public_key_path='/Users/linas/.ssh/hack-okapi.pem'
            ),
            Popularity(normalize=False),
            BPROkapi(host='54.72.18.118',
                            username='******',
                            #okapi_jar_dir='/Users/linas/devel/okapi/target/',
                            #okapi_jar_base_name='okapi-0.3.2-SNAPSHOT-jar-with-dependencies.jar',
                            public_key_path='/Users/linas/.ssh/hack-okapi.pem'
            )
]

#setup the environment
evaluator = Evaluator()

for m in models:
    m.fit(df)
    print m.getName().ljust(50),
    print evaluator.evaluate_model(m, df)

evaluator.close()#need this call to clean up the worker processes