aws / aws/amazon-sagemaker-examples

IP Insights - Creating Training & Test Data Set Errors

Open
#811 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
11k
Forks
7k
Avg merge
8h 29m
Merged PRs (30d)
8

Description

In ipinsights-tutorial available in SageMaker, there is an issue beginning in the 3rd step, Creating Training & Test Datasets

Running
```python
time_partition = datetime(2018, 11, 11)

# If you needed to normalize the timezones
# time_partition = datetime(2018, 11, 11, tzinfo=pytz.FixedOffset(0))

train_df = df[df['timestamp'] <= time_partition]
test_df = df[df['timestamp'] > time_partition]
```
Returns this error:
```
NameError Traceback (most recent call last)
in ()
----> 1 time_partition = datetime(2018, 11, 11)
2
3 # If you needed to normalize the timezones
4 # time_partition = datetime(2018, 11, 11, tzinfo=pytz.FixedOffset(0))
5

NameError: name 'datetime' is not defined
```

These errors continue down the remainder of the Notebook
```python
# Shuffle train data
train_df = train_df.sample(frac=1)
train_df.head()
```

That returns this traceback

```
NameError Traceback (most recent call last)
in ()
1 # Shuffle train data
----> 2 train_df = train_df.sample(frac=1)
3 train_df.head()

NameError: name 'train_df' is not defined
```

And in the Storing data on S3, errors are also encounter from this code block
```python
# Output dataset as headerless CSV
train_data = train_df.to_csv(index=False, header=False, columns=['user', 'ip_address'])
```

And that returns

```
NameError Traceback (most recent call last)
in ()
1 # Output dataset as headerless CSV
----> 2 train_data = train_df.to_csv(index=False, header=False, columns=['user', 'ip_address'])

NameError: name 'train_df' is not defined
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.