Ejemplo n.º 1
0
def row_errorsq(row, cluster_means):
    """
    Calculate the feature distance between each node and its cluster mean,
    to be used in an .apply to pandas dataframe

    Args:
        row : row of a pandas dataframe containing columns of features and
            one of assigned cluster number designated 'cnum'
        cluster_means : pandas dataframe of the mean of each feature in 'row'
            indexed by cluster number.
    Returns:
        feature distance, float
    """
    rowf = row.drop(['cnum'])
    return (fdist(rowf, cluster_means.ix[int(row.cnum)]))
Ejemplo n.º 2
0
def row_errorsq(row, cluster_means):
    rowf = row.drop(['cnum'])
    return (fdist(rowf, cluster_means.ix[int(row.cnum)]))**2