1 個回答
- 最新
- 最多得票
- 最多評論
0
Good morning,
Let me address your questions about SageMaker Canvas predictions:
- Regarding file paths and names:
- Your understanding is correct - when you make predictions in SageMaker Canvas, the results are automatically saved to S3 without allowing manual path/filename configuration
- The files are saved in your default SageMaker Canvas bucket with a structure like:
s3://{canvas-bucket-name}/inference/{model-id}/{timestamp}_batch_prediction.csv
- For identifying and accessing prediction files:
- Yes, there are several reliable ways to locate the prediction files:
- Using boto3 to list objects in the inference folder and sort by timestamp
- Using the S3 API's LastModified attribute to find the most recent file
- Filtering objects by the "_batch_prediction.csv" suffix
Here's a simple example of how you could find the most recent prediction file using Python in SageMaker Studio:
import boto3 from operator import itemgetter s3_client = boto3.client('s3') def get_latest_prediction(bucket_name, model_id): prefix = f'inference/{model_id}/' # List all objects in the inference folder for this model response = s3_client.list_objects_v2( Bucket=bucket_name, Prefix=prefix ) # Filter for CSV files and sort by last modified date if 'Contents' in response: files = [ { 'Key': obj['Key'], 'LastModified': obj['LastModified'] } for obj in response['Contents'] if obj['Key'].endswith('_batch_prediction.csv') ] if files: # Get the most recent file latest_file = max(files, key=itemgetter('LastModified')) return latest_file['Key'] return None
This code will help you locate the most recent prediction file for a specific model in your SageMaker Canvas bucket.
已回答 4 個月前
