aws / aws/amazon-sagemaker-examples
Addition/subtraction of integers and integer-arrays with Timestamp is no longer supported when using `Predicting driving speed violations with the Amazon SageMaker DeepAR algorithm`
- Dominant language
- Jupyter Notebook
- Stars
- 11k
- Forks
- 7k
- Avg merge
- 8h 29m
- Merged PRs (30d)
- 8
Description
I'm running into a consistent issue when calling the final cell of the example:
```python
predictor.set_prediction_parameters(freq, prediction_length)
list_of_df = predictor.predict(violation_list_training[:5])
```
Traceback:
```python
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in
1 predictor.set_prediction_parameters(freq, prediction_length)
----> 2 list_of_df = predictor.predict(violation_list_training[:5])
3 list_of_df
in predict(self, ts, cat, encoding, num_samples, quantiles)
28 """
29
---> 30 prediction_times = [x.index[-1]+1 for x in ts]
31 req = self.__encode_request(ts, cat, encoding, num_samples, quantiles)
32 res = super(DeepARPredictor, self).predict(req)
in (.0)
28 """
29
---> 30 prediction_times = [x.index[-1]+1 for x in ts]
31 req = self.__encode_request(ts, cat, encoding, num_samples, quantiles)
32 res = super(DeepARPredictor, self).predict(req)
pandas/_libs/tslibs/c_timestamp.pyx in pandas._libs.tslibs.c_timestamp._Timestamp.__add__()
TypeError: Addition/subtraction of integers and integer-arrays with Timestamp is no longer supported. Instead of adding/subtracting `n`, use `n * obj.freq`
```
I have tried this with both SageMaker 1.7.1:
```python
predictor = DeepARPredictor(endpoint=best_tuning_job_name,
sagemaker_session=sess,
content_type='application/json')
```
As well as SageMaker 2.7.0 (After specifying the correct predictor --> `sagemaker.predictor.Predictor`):
```python
predictor = DeepARPredictor(endpoint_name=endpoint_name,
sagemaker_session=sess,
serializer=sagemaker.serializers.JSONSerializer(),
deserializer=sagemaker.deserializers.BytesDeserializer()
)
```
I have also tried downgrading Pandas to `0.23.0` to no avail. Please can you show that this actually works initially as the published code doesn't work natively on a new SageMaker Notebook instance.
Contributor guide
Research direction
Start with the final cell of the driving-speed-violations notebook and the DeepARPredictor.predict method, especially the prediction_times calculation shown in the traceback. Reproduce the failure on a current SageMaker Notebook instance, then verify that the example runs successfully with the supported pandas and SageMaker APIs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, jupyter-notebook, machine-learning, pandas, python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100