Skip to content

Knn#12

Open
chamberi wants to merge 170 commits into
masterfrom
knn
Open

Knn#12
chamberi wants to merge 170 commits into
masterfrom
knn

Conversation

@chamberi
Copy link
Copy Markdown
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.
Comment thread .travis.yml Outdated
# command to install dependencies
install:
- pip install -e .[test]
# - pip install coveralls
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remove corpse code

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

# notifications
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

remove corpse code

Comment thread 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
Copy link
Copy Markdown

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

Comment thread src/knn.py
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
Copy link
Copy Markdown

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.

Comment thread src/knn.py
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):
Copy link
Copy Markdown

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.

Comment thread src/knn.py
win.append(self._get_winner(distance_list, k))
return win

def _get_winner(self, distance_list, k):
Copy link
Copy Markdown

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.

3 participants