KNNmodel.py 文件源码

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

项目:Machine_Learning_Playground 作者: yao23 项目源码 文件源码
def train(self, userFeatureTable, ratingsMat):
        userFeatureTable.loc[:, "age"] = userFeatureTable.loc[:, "age"] / 10.
        # ad hoc fix, make sure feature's range is similar
        self.knnModel = NearestNeighbors(n_neighbors=10, algorithm='ball_tree').fit(userFeatureTable)

        # ratingMat is the rating matrix
        self.ratingsMat = ratingsMat
        self.userFeatureTable = userFeatureTable
        self.userIds = self.userFeatureTable.index  # the actual order seen by the knnmodel
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号