Exemplo n.º 1
0
    def __init__(self,
                 test_scenes,
                 study_info_,
                 constraint_csv_removed_users=None):

        Model.__init__(
            self,
            ProximityModel.name,
            test_scenes,
            study_info_,
            constraint_csv_removed_users=constraint_csv_removed_users)

        prototype_array = []
        weight_array = []

        for feature in self.all_feature_keys:
            if feature != "shortest_distance":
                prototype_array.append(0)
                weight_array.append(0)
            else:
                x = self.feature_processer.convert_normal_value_to_standardised(
                    feature, 0)
                prototype_array.append(x)
                weight_array.append(1)

        self.prototype_array = np.array(prototype_array)
        self.weight_array = np.array(weight_array)
Exemplo n.º 2
0
    def __init__(self,
                 test_scenes,
                 study_info_,
                 constraint_csv_removed_users=None):
        Model.__init__(
            self,
            SimpleModel.name,
            test_scenes,
            study_info_,
            constraint_csv_removed_users=constraint_csv_removed_users)

        self.prototype_dictionary = dict()
        self.weight_dictionary = dict()

        in_prototype, in_weights = self.generate_arrays(
            {"bbox_overlap_proportion": 1})
        self.prototype_dictionary["in"] = self.prototype_dictionary[
            "inside"] = in_prototype
        self.weight_dictionary["in"] = self.weight_dictionary[
            "inside"] = in_weights

        on_prototype, on_weights = self.generate_arrays({
            "above_proportion": 1,
            "contact_proportion": 1
        })
        self.prototype_dictionary["on"] = self.prototype_dictionary[
            "on top of"] = on_prototype
        self.weight_dictionary["on"] = self.weight_dictionary[
            "on top of"] = on_weights

        above_prototype, above_weights = self.generate_arrays({
            "above_proportion":
            1,
            "horizontal_distance":
            0
        })
        self.prototype_dictionary["above"] = self.prototype_dictionary[
            "over"] = above_prototype
        self.weight_dictionary["above"] = self.weight_dictionary[
            "over"] = above_weights

        below_prototype, below_weights = self.generate_arrays({
            "below_proportion":
            1,
            "horizontal_distance":
            0
        })
        self.prototype_dictionary["below"] = self.prototype_dictionary[
            "under"] = below_prototype
        self.weight_dictionary["below"] = self.weight_dictionary[
            "under"] = below_weights

        against_prototype, against_weights = self.generate_arrays({
            "contact_proportion":
            1,
            "horizontal_distance":
            0
        })
        self.prototype_dictionary["against"] = against_prototype
        self.weight_dictionary["against"] = against_weights
Exemplo n.º 3
0
    def __init__(self,
                 preposition_model_dict,
                 test_scenes,
                 study_info_,
                 constraint_csv_removed_users=None):
        self.preposition_model_dict = preposition_model_dict

        Model.__init__(
            self,
            CSModel.name,
            test_scenes,
            study_info_,
            constraint_csv_removed_users=constraint_csv_removed_users)
    def __init__(
            self,
            preposition_model_dict: Dict[str,
                                         GeneratePrepositionModelParameters],
            test_scenes,
            study_info_,
            train_test_proportion=float(1),
            number_of_epochs=200,
            make_plots=False,
            test_prepositions=None):
        Model.__init__(self,
                       self.name,
                       test_scenes,
                       study_info_,
                       test_prepositions=test_prepositions)
        self.models = dict()
        self.preposition_model_dict = preposition_model_dict
        self.training_data_dict = {}
        self.callbacks = None
        self.number_of_epochs = number_of_epochs
        self.train_test_proportion = train_test_proportion
        self.make_plots = make_plots

        for p in self.test_prepositions:

            self.training_data_dict[
                p] = self.convert_train_dataframe_to_tfdataset(
                    preposition_model_dict[p].train_dataset, p)

            if self.train_test_proportion == 1:
                train = self.training_data_dict[p]
                model = self.train_model(p, train)
                self.callbacks = [high_acc_callback]
            else:
                train_amount = int(
                    len(self.training_data_dict[p]) *
                    self.train_test_proportion)
                train = self.training_data_dict[p].take(train_amount)
                test = self.training_data_dict[p].skip(train_amount)
                model = self.train_model(p, train, test)
            self.models[p] = model
    def __init__(self,
                 name,
                 test_scenes,
                 study_info_,
                 test_prepositions=PREPOSITION_LIST):
        """Summary
        
        Args:
            name (TYPE): Description
            test_scenes (TYPE): Description
            study_info_ (TYPE): Description
            :param test_prepositions:


        """

        Model.__init__(self,
                       name,
                       test_scenes,
                       study_info_,
                       test_prepositions=test_prepositions)
    def __init__(self,
                 train_scenes,
                 test_scenes,
                 study_info_,
                 features_to_remove,
                 train_test_proportion=float(1),
                 number_of_epochs=200,
                 make_plots=False,
                 test_prepositions=None):
        Model.__init__(self,
                       self.name,
                       test_scenes,
                       study_info_,
                       test_prepositions=test_prepositions)
        self.models = dict()
        self.train_scenes = train_scenes
        self.features_to_remove = features_to_remove
        self.number_of_epochs = number_of_epochs
        self.train_test_proportion = train_test_proportion
        self.make_plots = make_plots

        self.models = dict()
        self.train_datasets = dict()
        self.callbacks = None

        for p in self.test_prepositions:
            self.train_datasets[p] = self.prepare_train_dataset(p)
            if self.train_test_proportion == 1:
                train = self.train_datasets[p]
                model = self.train_model(p, train)
                self.callbacks = [perfect_acc_callback]
            else:
                train_amount = int(
                    len(self.train_datasets[p]) * self.train_test_proportion)
                train = self.train_datasets[p].take(train_amount)
                test = self.train_datasets[p].skip(train_amount)
                model = self.train_model(p, train, test)

            self.models[p] = model
Exemplo n.º 7
0
    def __init__(
            self,
            preposition_model_dict: Dict[str,
                                         GeneratePrepositionModelParameters],
            test_scenes,
            study_info_: StudyInfo,
            test_prepositions=PREPOSITION_LIST,
            constraint_csv_removed_users=None):
        self.preposition_model_dict = preposition_model_dict

        Model.__init__(
            self,
            PrototypeModel.name,
            test_scenes,
            study_info_,
            test_prepositions=test_prepositions,
            constraint_csv_removed_users=constraint_csv_removed_users)

        if len(test_scenes) < len(study_info_.scene_name_list):
            for p in self.test_prepositions:
                train_scenes = set(self.preposition_model_dict[p].train_scenes)
                if (any(x in train_scenes for x in test_scenes)):
                    raise ValueError("Train and test scene overlap.")
Exemplo n.º 8
0
    def __init__(self,
                 test_scenes,
                 study_info_,
                 constraint_csv_removed_users=None):
        Model.__init__(
            self,
            BestGuessModel.name,
            test_scenes,
            study_info_,
            constraint_csv_removed_users=constraint_csv_removed_users)

        self.prototype_dictionary = dict()
        self.weight_dictionary = dict()

        inside_prototype, inside_weights = self.generate_arrays(
            {"bbox_overlap_proportion": 1})
        self.prototype_dictionary["inside"] = inside_prototype
        self.weight_dictionary["inside"] = inside_weights

        in_prototype, in_weights = self.generate_arrays({
            "bbox_overlap_proportion":
            1,
            "location_control":
            1
        })
        self.prototype_dictionary["in"] = in_prototype
        self.weight_dictionary["in"] = in_weights

        on_prototype, on_weights = self.generate_arrays({
            "above_proportion": 1,
            "contact_proportion": 1,
            "support": 1
        })
        self.prototype_dictionary["on"] = on_prototype
        self.weight_dictionary["on"] = on_weights

        ontopof_prototype, ontopof_weights = self.generate_arrays({
            "above_proportion":
            1,
            "contact_proportion":
            1
        })
        self.prototype_dictionary["on top of"] = ontopof_prototype
        self.weight_dictionary["on top of"] = ontopof_weights

        above_prototype, above_weights = self.generate_arrays({
            "above_proportion":
            1,
            "horizontal_distance":
            0
        })
        self.prototype_dictionary["above"] = above_prototype
        self.weight_dictionary["above"] = above_weights

        over_prototype, over_weights = self.generate_arrays({
            "above_proportion":
            1,
            "f_covers_g":
            1
        })
        self.prototype_dictionary["over"] = over_prototype
        self.weight_dictionary["over"] = over_weights

        below_prototype, below_weights = self.generate_arrays({
            "below_proportion":
            1,
            "horizontal_distance":
            0
        })
        self.prototype_dictionary["below"] = below_prototype
        self.weight_dictionary["below"] = below_weights

        under_prototype, under_weights = self.generate_arrays({
            "below_proportion":
            1,
            "g_covers_f":
            1
        })
        self.prototype_dictionary["under"] = under_prototype
        self.weight_dictionary["under"] = under_weights

        against_prototype, against_weights = self.generate_arrays({
            "contact_proportion":
            1,
            "horizontal_distance":
            0,
            "location_control":
            0.5
        })
        self.prototype_dictionary["against"] = against_prototype
        self.weight_dictionary["against"] = against_weights