Exemple #1
0
    def setUp(self):
        dataset_filepath = config.ROOT + '/python/test/resource/NFLX_dataset_public_raw.py'
        dataset = import_python_file(dataset_filepath)

        np.random.seed(0)
        info_dict = {
            'corrupt_probability': 0.1,
        }

        self.dataset_reader = CorruptDataRawDatasetReader(dataset, input_dict=info_dict)
class CorruptDataDatasetReaderTest(unittest.TestCase):
    def setUp(self):
        dataset_filepath = config.ROOT + '/python/test/resource/NFLX_dataset_public_raw.py'
        dataset = import_python_file(dataset_filepath)

        np.random.seed(0)
        info_dict = {
            'corrupt_probability': 0.1,
        }

        self.dataset_reader = CorruptDataRawDatasetReader(dataset,
                                                          input_dict=info_dict)

    def test_opinion_score_2darray(self):
        os_2darray = self.dataset_reader.opinion_score_2darray
        self.assertAlmostEquals(np.mean(np.std(os_2darray, axis=1)),
                                0.79796204942957094,
                                places=4)

    def test_to_dataset(self):
        dataset = self.dataset_reader.to_dataset()

        old_scores = [
            dis_video['os']
            for dis_video in self.dataset_reader.dataset.dis_videos
        ]
        new_scores = [dis_video['os'] for dis_video in dataset.dis_videos]

        self.assertNotEquals(old_scores, new_scores)
Exemple #3
0
 def run_one_corrput_prob(corrupt_prob, dataset, seed):
     np.random.seed(seed)
     info_dict = {
         'corrupt_probability': corrupt_prob,
     }
     dataset_reader = CorruptDataRawDatasetReader(dataset,
                                                  input_dict=info_dict)
     subjective_model = model_class(dataset_reader)
     try:
         result = subjective_model.run_modeling(normalize_final=False)
     except ValueError as e:
         print 'Warning: {}, return result None'.format(e)
         result = None
     return dataset_reader, result
Exemple #4
0
class CorruptDataDatasetReaderTest(unittest.TestCase):

    def setUp(self):
        dataset_filepath = config.ROOT + '/python/test/resource/NFLX_dataset_public_raw.py'
        dataset = import_python_file(dataset_filepath)

        np.random.seed(0)
        info_dict = {
            'corrupt_probability': 0.1,
        }

        self.dataset_reader = CorruptDataRawDatasetReader(dataset, input_dict=info_dict)

    def test_opinion_score_2darray(self):
        os_2darray = self.dataset_reader.opinion_score_2darray
        self.assertAlmostEquals(np.mean(np.std(os_2darray, axis=1)), 0.79796204942957094, places=4)

    def test_to_dataset(self):
        dataset = self.dataset_reader.to_dataset()

        old_scores = [dis_video['os'] for dis_video in self.dataset_reader.dataset.dis_videos]
        new_scores = [dis_video['os'] for dis_video in dataset.dis_videos]

        self.assertNotEquals(old_scores, new_scores)