aws / amazon-sagemaker-examples

Example 📓 Jupyter notebooks that demonstrate how to build, train, and deploy machine learning models using 🧠 Amazon SageMaker.
https://sagemaker-examples.readthedocs.io
Apache License 2.0
10.03k stars 6.75k forks source link

Failed to publish an endpoint with custom sklearn model #1783

Open tthpham opened 3 years ago

tthpham commented 3 years ago

Hi,

I created a custom model from MultiOutputRegressor of sklearn. The train worked but I have the error AttributeError: module 'main' has no attribute 'DataTransformer' when publishing an end point of the model.

I found a topic with the same issue here and tried the proposition but it's still not working. [https://github.com/aws/amazon-sagemaker-examples/issues/725]

Here's my settings:

estimator = SKLearn( entry_point="script.py", role=role_name, train_instance_count=1, # training instance count train_instance_type=instance_type, # training instance type output_path=f's3://{bucket}/{prefix}/output', # S3 location for output data sagemaker_session=sess, framework_version='0.23-1', base_job_name=base_job_name, hyperparameters={'data_path': dataset_to_train}, dependencies=['DataTransformer.py'], source_dir='s3://mybucket/pyscripts/source.tar.gz')

The files script.py and DataTransformer.py is zipped and uploaded on S3, the 'source_dir' points to the .tar.gz file. How would I modify my script to make it work?

hongshanli23 commented 3 years ago

@tthpham do you have the link to the notebook?