Ejemplo n.º 1
0
 def persist(self, file_name: Text,
             model_dir: Text) -> Optional[Dict[Text, Any]]:
     """Persist this component to disk for future loading."""
     file_name = file_name + ".pkl"
     classifier_file = os.path.join(model_dir, file_name)
     utils.pycloud_pickle(classifier_file, self)
     return {"file": file_name}
Ejemplo n.º 2
0
    def persist(self, file_name: Text,
                model_dir: Text) -> Optional[Dict[Text, Any]]:
        """Persist this model into the passed directory."""

        file_name = file_name + ".pkl"
        classifier_file = os.path.join(model_dir, file_name)
        utils.pycloud_pickle(classifier_file, self)
        return {"file": file_name}
Ejemplo n.º 3
0
    def persist(self, file_name: Text,
                model_dir: Text) -> Optional[Dict[Text, Any]]:
        """Persist this model into the passed directory.

        Returns the metadata necessary to load the model again.
        """

        file_name = file_name + ".pkl"
        featurizer_file = os.path.join(model_dir, file_name)
        utils.pycloud_pickle(featurizer_file, self)
        return {"file": file_name}
Ejemplo n.º 4
0
    def persist(self, file_name: Text,
                model_dir: Text) -> Optional[Dict[Text, Any]]:
        """Persist this component to disk for future loading."""
        # n2g model just for function test
        n2g_file = os.path.join(model_dir, 'n2g_params.pkl')
        self.n2g.save(n2g_file)

        # total object
        file_name = file_name + ".pkl"
        classifier_file = os.path.join(model_dir, file_name)
        utils.pycloud_pickle(classifier_file, self)
        return {"file": file_name}
Ejemplo n.º 5
0
    def persist(self, file_name: Text,
                model_dir: Text) -> Optional[Dict[Text, Any]]:
        """Persist this model into the passed directory."""

        classifier_file_name = file_name + "_classifier.pkl"
        encoder_file_name = file_name + "_encoder.pkl"
        if self.clf:
            utils.pycloud_pickle(os.path.join(model_dir, classifier_file_name),
                                 self.clf)
            utils.pycloud_pickle(os.path.join(model_dir, encoder_file_name),
                                 self.le)
        return {
            "classifier": classifier_file_name,
            "encoder": encoder_file_name
        }