aws / aws/amazon-sagemaker-examples

[Content Improvement] An Introduction to SageMaker Random Cut Forests Shringe Function Improvements

Open
#3,745 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

**Link to the notebook**
[An Introduction to SageMaker Random Cut Forests](https://github.com/aws/amazon-sagemaker-examples/blob/main/introduction_to_amazon_algorithms/random_cut_forest/random_cut_forest.ipynb)

**What aspects of the notebook can be improved?**
- Current `shingle(data, shingle_size` functions miss out last row of the dataframe given. Look at the image below for more details.
![image](https://user-images.githubusercontent.com/44948482/213042765-ccfb8be8-9cb2-4a4d-af9c-e8a87adacb7e.png)

![image](https://user-images.githubusercontent.com/44948482/213043553-7f72649b-be7a-4129-bdff-d25c2548fa1d.png)

**What are your suggestions?**
- change `num_data - shingle_size` statement to `num_data - shingle_size + 1` statement.
(last row need to be seen)

**AS-IS**
```
def shingle(data, shingle_size):
num_data = len(data)
shingled_data = np.zeros((num_data - shingle_size, shingle_size))

for n in range(num_data - shingle_size):
shingled_data[n] = data[n : (n + shingle_size)]
return shingled_data
```
---
**TO-BE**
```
def shingle(data, shingle_size):
num_data = len(data)
shingled_data = np.zeros((num_data - shingle_size + 1, shingle_size))

for n in range(num_data - shingle_size + 1):
shingled_data[n] = data[n : (n + shingle_size)]
return shingled_data
```

Contributor guide

Open the contributing guide

Research direction

Open introduction_to_amazon_algorithms/random_cut_forest/random_cut_forest.ipynb and find the shingle(data, shingle_size) function. Check the current row-count calculation and loop range against the examples in the issue; it is done when the final valid shingle, including the last dataframe row, is included.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, numpy, python
Domain
machine-learning
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.