예제 #1
0
    def load_variables(cls, binary_class, data_path):
        self = MultipleSvm(binary_class)
        # dir(self).pp()
        file_path = os.path.join(data_path, self.variables_file_name)
        keys = json_helper.load(file_path)
        keys = map(tuple, keys)
        self.label_tuple = tuple(set(flatten_for_two_layers(keys)))

        for classifying_key in keys:
            file_prefix = self.gen_prefix_from_list(classifying_key)
            transfer_hash = self.gen_binary_transfer_hash(classifying_key)

            self.classifying_hash[classifying_key] = self.binary_class.load_variables(data_path, file_prefix)

        return self
예제 #2
0
    def load_variables(cls, data_path="dataset", prefix=""):
        paths = cls.get_file_paths(data_path, prefix)

        selected_data_matrix = numpy.load(paths["selected_data_matrix"])
        selected_alphas_label_matrix = numpy.load(paths["selected_alphas_label_matrix"])

        other_variables = json_helper.load(paths["other_variables"])

        other_variables["transfer_hash"] = dict(other_variables["transfer_hash"])

        return cls(
            selected_data_matrix,
            selected_alphas_label_matrix,
            other_variables["b"],
            other_variables["arg_exp"],
            other_variables["transfer_hash"],
        )