Skip to content

Conversation

@chamberi
Copy link
Owner

No description provided.

CCallahanIV and others added 30 commits January 16, 2017 12:44
…o bst

sdf building a binary search tree.
…ctures into traversal-bst

g
g Lines starting with '#' will be ignocquire post_order_trav. red, and an empty message aborts
chamberi and others added 27 commits February 2, 2017 13:30
…ctures into decision-tree

Merging branch for decision tree.
.travis.yml Outdated
# command to install dependencies
install:
- pip install -e .[test]
# - pip install coveralls

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove corpse code

.travis.yml Outdated
script:
- py.test --cov=. --cover-report term-missing

# notifications

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove corpse code

src/knn.py Outdated
self.data = data
if k > len(data) or type(k) is not int or k <= 0:
raise ValueError("The number of neighbors to predict against must be an integer greater than 0 and less than size of data.")
self.k = 5

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why set self.k if you have it coming into the method as an optional parameter

for data_idx in range(len(self.data)):
squares_sum = 0.0
for item_idx in range(len(eval_item)):
squares_sum += (eval_item[item_idx] - self.data[data_idx][item_idx]) ** 2

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're missing out on the power of numpy or pandas to perform math operations across an entire data set. The distance calculation could be one-lined.

raise ValueError("The number of neighbors to predict against must be an integer greater than 0 and less than size of data.")
self.k = 5

def predict(self, evals, k=None):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you providing k here? You set it when you initialize the object.

win.append(self._get_winner(distance_list, k))
return win

def _get_winner(self, distance_list, k):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you getting k here when you've defined it on init?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants