Ejemplo n.º 1
0
    def save(self, model_dir, force=False):
        """
        Save the model to a directory.
        The force parameter is deprecated (ignored)
        """

        if not path.exists(model_dir):
            os.mkdir(model_dir)

        liblinear_save_model(path.join(model_dir, 'liblinear_model'),
                             self.c_model)
        options_file = path.join(model_dir, 'options.pickle')
        cPickle.dump(self.param_options, open(options_file, 'wb'), -1)

        idf_file = path.join(model_dir, 'idf.pickle')
        cPickle.dump(self.idf, open(idf_file, 'wb'), -1)
Ejemplo n.º 2
0
    def save(self, model_dir, force=False):
        """
        Save the model to a directory. If *force* is set to ``True``,
        the existing directory will be overwritten; otherwise,
        :class:`IOError` will be raised.
        """

        if path.exists(model_dir):
            if force:
                shutil.rmtree(model_dir)
            else :
                raise OSError('Please use force option to overwrite the existing files.')
        os.mkdir(model_dir)

        liblinear_save_model(path.join(model_dir,'liblinear_model'), self.c_model)
        options_file = path.join(model_dir,'options.pickle')
        cPickle.dump(self.param_options, open(options_file,'wb'),-1)

        idf_file = path.join(model_dir,'idf.pickle')
        cPickle.dump(self.idf, open(idf_file,'wb'),-1)
Ejemplo n.º 3
0
    def save(self, model_dir, force=False):
        """
        Save the model to a directory. If *force* is set to ``True``,
        the existing directory will be overwritten; otherwise,
        :class:`IOError` will be raised.
        """

        if path.exists(model_dir):
            if force:
                shutil.rmtree(model_dir)
            else :
                raise OSError('Please use force option to overwrite the existing files.')
        os.mkdir(model_dir)

        liblinear_save_model(path.join(model_dir,'liblinear_model'), self.c_model)
        options_file = path.join(model_dir,'options.pickle')
        pickle.dump(self.param_options, open(options_file,'wb'),-1)

        idf_file = path.join(model_dir,'idf.pickle')
        pickle.dump(self.idf, open(idf_file,'wb'),-1)