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 = { 'selected_subjects': range(5), } self.dataset_reader = SelectSubjectRawDatasetReader(dataset, input_dict=info_dict)
class SelectedSubjectDatasetReaderTest(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 = { 'selected_subjects': range(5), } self.dataset_reader = SelectSubjectRawDatasetReader(dataset, input_dict=info_dict) def test_read_dataset_stats(self): self.assertEquals(self.dataset_reader.num_ref_videos, 9) self.assertEquals(self.dataset_reader.num_dis_videos, 79) self.assertEquals(self.dataset_reader.num_observers, 5) def test_opinion_score_2darray(self): os_2darray = self.dataset_reader.opinion_score_2darray self.assertEquals(os_2darray.shape, (79, 5)) 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)
def run_one_num_subject(num_subject, dataset, seed): np.random.seed(seed) total_subject = len(dataset.dis_videos[0]['os']) info_dict = { 'selected_subjects': np.random.permutation(total_subject)[:num_subject] } dataset_reader = SelectSubjectRawDatasetReader( dataset, input_dict=info_dict) subjective_model = model_class(dataset_reader) result = subjective_model.run_modeling(normalize_final=False) return dataset_reader, result