Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
Reuse a scikit learn model .pkl in AWS Lambda

I am a beginner in AWS and I trained on my computer a RandomForestClassifier with scikit-learn and I used joblib to get my model in pkl format.

Now I would like, to reuse this RandomForest in AWS Lambda. Since it needs sklearn.externals to load my model again, I have made a Zip directory which contains Numpy, Scipy, sklearn, my code and my model in pkl format. I put this zip in a S3 bucket to execute my code in Lambda.

I would like to know if then, it is possible to use this model using model.predict() ? I didn't find any documentation about this specific problem.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Actually, I succeed using URLs. I put my model .pkl in a S3 Bucket, and I can get it using urllib2.

Here is my code, if anyone ever encounters the same problem :

req = urllib2.Request(url=url_model)
f = urllib2.urlopen(req)
model = cPickle.load(f)

It only works if the file is public. If you need it to be private, you can generate a presigned URL using boto3 like this :

url_model = s3.generate_presigned_url(
    ClientMethod='get_object',
    ExpiresIn=1,
    Params={
        'Bucket': 'my-bucket',
        'Key': 'mymodel.pkl'
    }
)
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!