def test_plot(self): fs = FileStreamExplicit("test/test_dataset/test.data", sep="\t") cf = MFExplicitSGD() ev = PrequentialEvaluatorExplicit(cf) st = EvaluationStatic(fs.stream, ev) st.evaluate() self.assertEqual(st.plot(), None)
def test_evaluate(self): fs = FileStreamExplicit("test/test_dataset/test.data", sep="\t") cf = MFExplicitSGD() ev = PrequentialEvaluatorExplicit(cf) st = EvaluationStatic(fs.stream, ev) st.evaluate() self.assertEqual(len(st.err_rate), len(st.stream)) self.assertEqual(len(st.elap_rec), len(st.stream)) self.assertEqual(len(st.elap_nr), len(st.stream))
def test_init(self): fs = FileStreamExplicit("test/test_dataset/test.data", sep="\t") cf = MFExplicitSGD() ev = PrequentialEvaluatorExplicit(cf) st = EvaluationStatic(fs.stream, ev) self.assertEqual(st.stream, fs.stream) self.assertEqual(st.x, range(0, len(fs.stream))) self.assertEqual(st.evaluator, ev) self.assertEqual(st.err_rate, []) self.assertEqual(st.elap_nr, []) self.assertEqual(st.elap_rec, [])
import sys import getopt from algorithms.collaborative_filtering.matrix_factorization\ .explicit_feedback import MFExplicitSGD from evaluators.prequential.explicit_feedback import ( PrequentialEvaluatorExplicit) from stream.file_stream.explicit import FileStreamExplicit from graphic import EvaluationStatic path = getopt.getopt(sys.argv[1:], "")[1][0] output = getopt.getopt(sys.argv[1:], "")[1][1] fs = FileStreamExplicit(path, sep="\t") cf = MFExplicitSGD(lf=20) ev = PrequentialEvaluatorExplicit(cf) stat = EvaluationStatic(fs.stream, ev) stat.process(path=output)