Ejemplo n.º 1
0
    def iter_func_seqs(self) -> Generator[List[BaseGenerator], None, None]:
        generators: Dict[str, BaseGenerator] = load_generators()
        if self.model_store is None or 'function-model' not in self.model_store:
            model = ModelStore({'function-model': self.model_path})
        else:
            model = self.model_store

        if self.use_old_featurization:
            from autopandas_v2.ml.featurization_old.featurizer import RelationGraph
            from autopandas_v2.ml.featurization_old.options import GraphOptions
        else:
            from autopandas_v2.ml.featurization.featurizer import RelationGraph
            from autopandas_v2.ml.featurization.options import GraphOptions

        options = GraphOptions()
        graph: RelationGraph = RelationGraph(options)
        graph.from_input_output(self.iospec.inputs, self.iospec.output)
        encoding = graph.get_encoding(get_mapping=False)

        str_seqs, probs = list(
            zip(*model.predict_graphs('function-model', [encoding],
                                      top_k=self.top_k)[0]))
        str_seqs = [i.split(':') for i in str_seqs]
        model.close()

        for str_seq in str_seqs:
            result = [generators[i] for i in str_seq]
            if self.typecheck(result, self.iospec.output):
                logger.info(str_seq)
                yield result
            else:
                logger.warn("Skipping", str_seq)
Ejemplo n.º 2
0
    def iter_func_seqs(self) -> Generator[List[BaseGenerator], None, None]:
        generators: Dict[str, BaseGenerator] = load_generators()
        if self.use_spec_funcs and self.iospec.funcs is not None:
            generators = {k: v for k, v in generators.items() if k in self.iospec.funcs}

        if self.use_spec_seqs and self.iospec.seqs is not None:
            for seq in self.iospec.seqs:
                yield [generators[self.iospec.funcs[i]] for i in seq]

            return

        raise NotImplementedError("Iteration of function sequences not defined yet")
Ejemplo n.º 3
0
    def iter_func_seqs(self) -> Generator[List[BaseGenerator], None, None]:
        generators: Dict[str, BaseGenerator] = load_generators()
        model = RelGraphInterface.from_model_dir(self.model_path)
        if self.use_old_featurization:
            from autopandas_v2.ml.featurization_old.featurizer import RelationGraph
            from autopandas_v2.ml.featurization_old.options import GraphOptions
        else:
            from autopandas_v2.ml.featurization.featurizer import RelationGraph
            from autopandas_v2.ml.featurization.options import GraphOptions

        options = GraphOptions()
        graph: RelationGraph = RelationGraph(options)
        graph.from_input_output(self.iospec.inputs, self.iospec.output)
        encoding = graph.get_encoding(get_mapping=False)

        str_seqs, probs = list(zip(*model.predict_graphs([encoding], top_k=self.top_k)[0]))
        str_seqs = [i.split(':') for i in str_seqs]
        model.close()

        for str_seq in str_seqs:
            yield [generators[i] for i in str_seq]
Ejemplo n.º 4
0
 def init(cls, args: ArgNamespace):
     cls.args = args
     cls.generators = load_generators()
     if cls.args.debug:
         logger.info("Loaded {} generators in process {}".format(
             len(cls.generators), os.getpid()))