# Tag Info

Accepted

### Removing neighbors in a point cloud

1. Introduction It is not a good plan to leave code running for 30 hours. Until you have analyzed the code, and have figured out how its runtime varies according to the size of the input, then you ...
• 49.6k

### Finding the closest point to a list of points

All your code could be rewritten as: ...
• 401

### K-Means image segmentation algorithm

I'm not familiar with image processing at all, so I cannot give you any advice about your algorithm implementation. However, there are quite a few things I'd like to say about good practices and code ...
• 5,228

### Removing neighbors in a point cloud

Gareth provided some excellent ideas, for which I will suggest a very similar solution, only using scipy instead of rtree. I ...
• 233

### K-Means image segmentation algorithm

I want to reinforce a point that Ben Steffan made in his answer: This part is really bad: std::vector<Pixel*> m_pixels; This would be much, much better: <...
• 6,217

### Closest Pair algorithm implementation in C++

Your code can be improved in regard to its efficiency and its readability. But first of all, don't write that using namespace std. Efficiency You create a lot of ...
• 5,757

### Finding the closest point to a list of points

By using a kd-tree computing the distance between all points it's not needed for this type of query. It's also built in into scipy and can speed up these types of programs enormously going from O(n^2) ...
• 273
Accepted

### K-means clustering implemented in Python 3

import numpy as np class kmeans(): Use a PEP 8 checker such as pycodestyle or flake8. Integrate it into your file editor or IDE, if you're not doing it already. ...
• 6,904

### Given a collection of points on a 2D plane, find the pair that is closest to each other

Comments out of sync with code ...
• 33.6k
Accepted

### Clustering 16 million records in parallel

Hard to tell without sample data, but lets start with a cleaned up version as there's soo much duplicated code here and the formatting is inconsistent. The require ...
• 11.1k
Accepted

### KNN algorithm implemented in Python

First a style nitpick: Python has an official style-guide, PEP8, which recommends using lower_case_with_underscores for variable and function names instead of ...
• 41k
Accepted

### Cosine similarity of one vector with many

I'm using Microsoft R (with Intel MKL) which makes matrix multiplications faster, but for fair comparison I set it to be single threaded. setMKLthreads(1) In my ...
Accepted

### Simple natural language classifier

Welcome to Code Review! This is an interesting program; thanks for sharing! To help you maintain it ... baseDict appears to be unused, and can be removed. Ditto ...
• 33.9k
Accepted

### Implementation of K-means

Unnecessary type checking In update_h_params, you write ...
Accepted

### Calculation of the Distance Matrix in the K-Means Algorithm in MATLAB

Your Distance Matrix Calculation You wrote the code (I summarize it for the Distance Matrix): ...
• 582
Accepted

### Pole (Hackerrank)

This is my code, but the complexity is very high. How high? Python has standard formatting conventions, known as PEP8. There are free tools to lint code to those standards (e.g. this online checker, ...
• 24.1k
Accepted

### Given a collection of points on a 2D plane, find the pair that is closest to each other

Consider using range-based for loop If you don't need information about index of element, then you can iterate over the vector of points with following code: <...
• 121
Accepted

### Selecting kids for a Christmas play with similar heights

Time is mostly spent in I/O I played with your program and found that most of the time was spent doing I/O. However, from your comments, it appears you already improved your I/O so that your best ...
• 28.5k

### Finding closest pair of 2D points, using divide-and-conquer

Here are some observations that may help you improve your code. Use all required #includes The code uses std::vector which ...
• 66.5k
Accepted

### Zip code reduce function

An alternative ...
• 21.7k
Accepted

### Clustering nodes with Hamming distance < 3

Generic comments Your spacing is very odd and inconsistent, which makes reading the code a bit harder. 2 blank lines before function definition, spaces around operators, and after a coma is what is ...
Accepted

### Predict new ratings for each user based on their pearson correlation with other users

You have incorrect indexing in the loop. Better version with mapply and correct indexing: ...
• 366
Accepted

### "Similar Destinations" challenge

I've managed to solve the problem after a bit of selective profiling. It would seem that my initial hunch was right. The problem had less to do with the algorithm and more towards the data structures ...
• 171
Accepted

### A Simple Cluster Generator v0.2

This code looks pretty good, but here are some things that may help you further improve it. Separate interface from implementation The interface goes into the .h ...
• 66.5k
Accepted

### A Simple Cluster Generator v0.3

#include <fstream> #include <vector> #include <string> It's really nice to see that you are only #includeing ...
• 3,295

### DBSCAN "region query" too slow; implement a tree?

You don't provide much information, which is unfortunate, since this kind of optimization problem relies on knowing how to "skew" the code in order to get better performance. For example, are your ...
• 12.4k
Accepted

### K-Nearest Neighbors in pure Python

Assumption: k << N, where N = len(points) There is no need to sort the entire list of points! Instead, take the first k points, and determine their distance ...
• 33.9k

### k-means using numpy

The code looks good, I wouldn't suggest anything as needing to be changed. In line with your question about possible ways to use Numpy better, I'll offer a few things you could try: You can pass low/...
• 2,030