models.py 892 B

1234567891011121314151617181920212223242526272829303132333435
  1. # Copyright (c) 2017-present, Facebook, Inc.
  2. # All rights reserved.
  3. #
  4. # This source code is licensed under the BSD-style license found in the
  5. # LICENSE file in the root directory of this source tree. An additional grant
  6. # of patent rights can be found in the PATENTS file in the same directory.
  7. from __future__ import absolute_import
  8. from __future__ import division
  9. from __future__ import print_function
  10. from __future__ import unicode_literals
  11. import pickle
  12. # fb-block 1 start
  13. import pkg_resources
  14. # fb-block 1 end
  15. # fb-block 2
  16. def get_prophet_stan_model():
  17. """Load compiled Stan model"""
  18. # fb-block 3
  19. # fb-block 4 start
  20. model_file = pkg_resources.resource_filename(
  21. 'fbprophet',
  22. 'stan_model/prophet_model.pkl',
  23. )
  24. # fb-block 4 end
  25. with open(model_file, 'rb') as f:
  26. return pickle.load(f)
  27. prophet_stan_model = get_prophet_stan_model()