pca.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:prince 作者: MaxHalford 项目源码 文件源码
def row_cosine_similarities(self):
        """The squared row cosine similarities.

        The row cosine similarities are obtained by calculating the cosine of the angle shaped by
        the row principal coordinates and the row principal components. This is calculated by
        squaring each row projection coordinate and dividing each squared coordinate by the sum of
        the squared coordinates, which results in a ratio comprised between 0 and 1 representing the
        squared cosine.

        Returns:
            pandas.DataFrame: A dataframe of shape (`n`, `k`) containing the squared row cosine
            similarities.
        """
        squared_coordinates = np.square(self.row_principal_coordinates)
        total_squares = squared_coordinates.sum(axis='columns')
        return squared_coordinates.div(total_squares, axis='rows')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号