Esempio n. 1
0
    def setUp(self):
        dataset_filepath = SurealConfig.test_resource_path('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)
Esempio n. 2
0
class CorruptDataDatasetReaderTest(unittest.TestCase):
    def setUp(self):
        dataset_filepath = SurealConfig.test_resource_path(
            '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.assertAlmostEqual(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.assertNotEqual(old_scores, new_scores)
Esempio n. 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