lsClassifier.py 文件源码

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

项目:USTC_AILab2 作者: overflocat 项目源码 文件源码
def lsClassifier(trainData, trainLabel, testData, testLabel, lambdaS):
    reg = linear_model.Ridge(alpha=lambdaS)
    reg.fit(trainData, trainLabel.tolist())

    W = reg.coef_
    testResult = np.array(testData.dot(W))
    testResult = np.where(testResult > 0, 1, -1).astype(np.int32)
    accu = np.sum(np.where(testResult == testLabel, 1, 0)) / float(testLabel.shape[0])

    return testResult, accu
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号