Пример #1
0
 def _to_file(filename, param_dict, model_dict):
     # override TrainTestModel._to_file
     # special handling of libsvmnusvr: save .model differently
     info_to_save = {'param_dict': param_dict,
                     'model_dict': model_dict.copy()}
     svm_model = info_to_save['model_dict']['model']
     info_to_save['model_dict']['model'] = None
     with open(filename, 'wb') as file:
         pickle.dump(info_to_save, file)
     svmutil.svm_save_model(filename + '.model', svm_model)
Пример #2
0
    def to_file(self, filename):
        """
        override TrainTestModel.to_file
        """

        self._assert_trained()

        # special handling of libsvmnusvr: save .model differently
        model_dict_copy = self.model_dict.copy()
        model_dict_copy['model'] = None
        info_to_save = {'param_dict': self.param_dict,
                        'model_dict': model_dict_copy}
        svmutil.svm_save_model(filename + '.model', self.model_dict['model'])

        with open(filename, 'wb') as file:
            pickle.dump(info_to_save, file)
Пример #3
0
    def to_file(self, filename):
        """
        override TrainTestModel.to_file
        """

        self._assert_trained()

        # special handling of libsvmnusvr: save .model differently
        model_dict_copy = self.model_dict.copy()
        model_dict_copy['model'] = None
        info_to_save = {
            'param_dict': self.param_dict,
            'model_dict': model_dict_copy
        }
        svmutil.svm_save_model(filename + '.model', self.model_dict['model'])

        with open(filename, 'wb') as file:
            pickle.dump(info_to_save, file)