Skip to content

Instantly share code, notes, and snippets.

@RoaldSchuring
Created July 6, 2019 13:47
Show Gist options
  • Save RoaldSchuring/f69f60a3b82b329156f47e2850d7f643 to your computer and use it in GitHub Desktop.
Save RoaldSchuring/f69f60a3b82b329156f47e2850d7f643 to your computer and use it in GitHub Desktop.
Running SKLearn script in Sagemaker
from sagemaker.sklearn.estimator import SKLearn
script_path = 'sklearn_nearest_neighbors.py'
sess = sagemaker.Session()
# run the Scikit-Learn script
sklearn = SKLearn(
entry_point=script_path,
train_instance_type="ml.m5.large",
role=role,
sagemaker_session=sess,
hyperparameters={'n_neighbors': 10, 'metric': 'cosine'})
sklearn.fit({'train': 's3://data-science-wine-reviews/nearest_neighbors/data/wine_review_vectors.csv'})
# deploy the model to a SageMaker endpoint
predictor = sklearn.deploy(initial_instance_count=1, instance_type="ml.m5.large")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment