knn.py 文件源码

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

项目:DataMiningCompetitionFirstPrize 作者: lzddzh 项目源码 文件源码
def learn(x, y, test_x):
    weight_list = []
    for j in range(len(y)):
        if y[j] == "0":
            weight_list.append(variables.weight_0_gdbt)
        if y[j] == "1000":
            weight_list.append(variables.weight_1000_gdbt)
        if y[j] == "1500":
            weight_list.append(variables.weight_1500_gdbt)
        if y[j] == "2000":
            weight_list.append(variables.weight_2000_gdbt)

    clf = KNeighborsClassifier(1, weight_list).fit(x, y)

    prediction_list = clf.predict(test_x)
    return prediction_list
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号