kmeans.py
def assign_points(data_points, centers):
    """
    Given a data set and a list of points betweeen other points,
    assign each point to an index that corresponds to the index
    of the center point on it's proximity to that point.
    Return a an array of indexes of centers that correspond to
    an index in the data set; that is, if there are N points
    in `data_set` the list we return will have N elements. Also
    If there are Y points in `centers` there will be Y unique
    possible values within the returned list.
    """
    assignments = []
    for point in data_points:
        shortest = ()  # positive infinity
        shortest_index = 0
        for i in xrange(len(centers)):
            val = distance(point, centers[i])
            if val < shortest:
                shortest = val
                shortest_index = i
        assignments.append(shortest_index)
    return assignments

    Given a data set and a list of points betweeen other points,
    assign each point to an index that corresponds to the index
    of the center point on it's proximity to that point.
    Return a an array of indexes of centers that correspond to
    an index in the data set; that is, if there are N points
    in `data_set` the list we return will have N elements. Also
    If there are Y points in `centers` there will be Y unique
    possible values within the returned list.
    
Given a data set and a list of points betweeen other points,
assign each point to an index that corresponds to the index
of the center point on it's proximity to that point.
Return a an array of indexes of centers that correspond to
an index in the data set; that is, if there are N points
in `data_set` the list we return will have N elements. Also
If there are Y points in `centers` there will be Y unique
possible values within the returned list.
Given a data set and a list of points betweeen other points assign each point to an index that corresponds to the index of the center point on it ' s proximity to that point . Return a an array of indexes of centers that correspond to an index in the data set ; that is if there are N points in ` data_set ` the list we return will have N elements . Also If there are Y points in ` centers ` there will be Y unique possible values within the returned list .
def assign_points(data_points, centers):
    assignments = []
    for point in data_points:
        shortest = ()  
        shortest_index = 0
        for i in xrange(len(centers)):
            val = distance(point, centers[i])
            if val < shortest:
                shortest = val
                shortest_index = i
        assignments.append(shortest_index)
    return assignments
def assign_points ( data_points , centers ) : assignments = [ ] for point in data_points : shortest = ( ) shortest_index = 0 for i in xrange ( len ( centers ) ) : val = distance ( point , centers [ i ] ) if val < shortest : shortest = val shortest_index = i assignments . append ( shortest_index ) return assignments
Given a data set and a list of points betweeen other points,
assign each point to an index that corresponds to the index
of the center point on it's proximity to that point.
Given a data set and a list of points betweeen other points assign each point to an index that corresponds to the index of the center point on it ' s proximity to that point .
"""
    Given a data set and a list of points betweeen other points,
    assign each point to an index that corresponds to the index
    of the center point on it's proximity to that point.
    Return a an array of indexes of centers that correspond to
    an index in the data set; that is, if there are N points
    in `data_set` the list we return will have N elements. Also
    If there are Y points in `centers` there will be Y unique
    possible values within the returned list.
    """ # positive infinity
data_points
centers