mirror of
https://github.com/saymrwulf/prophet.git
synced 2026-11-16 08:38:30 +00:00
Fix Issue with Pickling Models in Python3.6 because of Logger Attribute (#1452)
* Fix issue with pickeling models due to logger * Fixes Model Pickle Error in Python3.6 as described in #1361
This commit is contained in:
parent
5fe3be86c5
commit
98f2a7be18
2 changed files with 7 additions and 6 deletions
|
|
@ -150,7 +150,7 @@ class Prophet(object):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug("Unable to load backend %s (%s), trying the next one", i.name, e)
|
logger.debug("Unable to load backend %s (%s), trying the next one", i.name, e)
|
||||||
else:
|
else:
|
||||||
self.stan_backend = StanBackendEnum.get_backend_class(stan_backend)(logger)
|
self.stan_backend = StanBackendEnum.get_backend_class(stan_backend)()
|
||||||
|
|
||||||
logger.debug("Loaded stan backend: %s", self.stan_backend.get_type())
|
logger.debug("Loaded stan backend: %s", self.stan_backend.get_type())
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,15 @@ from collections import OrderedDict
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
import pickle
|
import pickle
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import logging
|
||||||
|
logger = logging.getLogger('fbprophet.models')
|
||||||
|
|
||||||
|
|
||||||
class IStanBackend(ABC):
|
class IStanBackend(ABC):
|
||||||
def __init__(self, logger):
|
def __init__(self):
|
||||||
self.model = self.load_model()
|
self.model = self.load_model()
|
||||||
self.logger = logger
|
|
||||||
self.stan_fit = None
|
self.stan_fit = None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
@ -82,7 +83,7 @@ class CmdStanPyBackend(IStanBackend):
|
||||||
except RuntimeError as e:
|
except RuntimeError as e:
|
||||||
# Fall back on Newton
|
# Fall back on Newton
|
||||||
if kwargs['algorithm'] != 'Newton':
|
if kwargs['algorithm'] != 'Newton':
|
||||||
self.logger.warning(
|
logger.warning(
|
||||||
'Optimization terminated abnormally. Falling back to Newton.'
|
'Optimization terminated abnormally. Falling back to Newton.'
|
||||||
)
|
)
|
||||||
kwargs['algorithm'] = 'Newton'
|
kwargs['algorithm'] = 'Newton'
|
||||||
|
|
@ -244,7 +245,7 @@ class PyStanBackend(IStanBackend):
|
||||||
self.stan_fit = self.model.optimizing(**args)
|
self.stan_fit = self.model.optimizing(**args)
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
# Fall back on Newton
|
# Fall back on Newton
|
||||||
self.logger.warning(
|
logger.warning(
|
||||||
'Optimization terminated abnormally. Falling back to Newton.'
|
'Optimization terminated abnormally. Falling back to Newton.'
|
||||||
)
|
)
|
||||||
args['algorithm'] = 'Newton'
|
args['algorithm'] = 'Newton'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue