简体   繁体   中英

Import PKL in sagemaker AWS to publish API

I have a.pkl file that is the result of a trained model. And I want to create an endpoint from sage maker to be able to consume the predictions, and I have already managed to read the file from s3 but I can't find exact documentation on how to expose the "compiled" as API

s3 = boto3.resource('s3')
bucket = s3.Bucket("sagemake-models-workshop").Object("pikle- 
file/contatos/xgb_contratos_mensual_RandomizedSearchLinux.pkl").get()['Body'].read()

bucket_pickle = pickle.loads(bucket)

output:

bucket_pickle

XGBRegressor(base_score=0.5, booster='gbtree', colsample_bylevel=1,
         colsample_bynode=1, colsample_bytree=0.1, gamma=0, gpu_id=-1,
         importance_type='gain', interaction_constraints='',
         learning_rate=0.33, max_delta_step=0, max_depth=3,
         min_child_weight=1, missing=nan, monotone_constraints='()',
         n_estimators=150, n_jobs=0, num_parallel_tree=1, random_state=0,
         reg_alpha=0, reg_lambda=1, scale_pos_weight=1, subsample=1,
         tree_method='exact', validate_parameters=1, verbosity=None)

If your model is an XGBoost model you can look at deploying it using the XGBoost Framework container. Please see this link for details on Bring Your Own Model for XGBoost.

I work for AWS and my opinions are my own.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM