Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
364 views
in Technique[技术] by (71.8m points)

python - Load XGBoost from an s3 bucket

I have an XGBoost model sitting in an AWS s3 bucket which I want to load. currently, I'm attempting to use s3fs to load the data, but I keep getting type errors:

from s3fs.core import S3FileSystem
import xgboost as xgb

fs = S3FileSystem()
bst = xgb.XGBClassifier()

with fs.open(f'{bucket}/{modelPath}', mode='rb') as f:
    bst.load_model(f.read())

I would include output, this I'm pretty sure this approach is completely wrong. How do I get this working?

(also, I think I would rather use boto)

question from:https://stackoverflow.com/questions/65894296/load-xgboost-from-an-s3-bucket

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Provided I don't receive a better answer, one good approach would be to download the file onto the lambda functions storage, then load it with bst.load_model('path_to_model'). based on this, each lambda function is allocated 500 MB of non persistent storage, which actually sits around for subsequent invocations of the same lambda function (until the lambda function goes cold).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...