2021年1月17日星期日

Load Saved CatBoost Model (.cbm) from Google Cloud Storage

I am trying to create a script which loads a saved CatBoost model from a Cloud Storage bucket, and uses it to make predictions. However, I am unable to successfully load the file. CatBoost throws an error that the model file does not exist, though I've copied the path directly from the UI.

#Specify model path  path = 'gs://bucket_id/model-name'    # Load model  from_file = CatBoostClassifier()  from_file.load_model(path)    model.predict(X_eval)  
---------------------------------------------------------------------------  CatBoostError                             Traceback (most recent call last)  <ipython-input-9-f7a6068f5718> in <module>       70        71 if __name__ == "__main__":  ---> 72     main('data','context')    <ipython-input-9-f7a6068f5718> in main(data, context)       42     # Load model       43     from_file = CatBoostClassifier()  ---> 44     from_file.load_model(path)       45        46     model.predict(X_eval)    /opt/conda/lib/python3.7/site-packages/catboost/core.py in load_model(self, fname, format, stream, blob)     2655      2656         if fname is not None:  -> 2657             self._load_model(fname, format)     2658         elif stream is not None:     2659             self._load_from_stream(stream)    /opt/conda/lib/python3.7/site-packages/catboost/core.py in _load_model(self, model_file, format)     1345             raise CatBoostError("Invalid fname type={}: must be str().".format(type(model_file)))     1346   -> 1347         self._object._load_model(model_file, format)     1348         self._set_trained_model_attributes()     1349         for key, value in iteritems(self._get_params()):    _catboost.pyx in _catboost._CatBoost._load_model()    _catboost.pyx in _catboost._CatBoost._load_model()    CatBoostError: catboost/libs/model/model_import_interface.h:19: Model file doesn't exist: gs://bucket_id/model-name  
https://stackoverflow.com/questions/65767595/load-saved-catboost-model-cbm-from-google-cloud-storage January 18, 2021 at 09:00AM

没有评论:

发表评论