10.1 Adaboost classifer.py 文件源码

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

项目:ML-note 作者: JasonK93 项目源码 文件源码
def test_AdaBoostClassifier(*data):
    '''
    test Ada score with different number of classifiers
    :param data: train_data, test_data, train_value, test_value
    :return: None
    '''
    X_train,X_test,y_train,y_test=data
    clf=ensemble.AdaBoostClassifier(learning_rate=0.1)
    clf.fit(X_train,y_train)
    ## graph
    fig=plt.figure()
    ax=fig.add_subplot(1,1,1)
    estimators_num=len(clf.estimators_)
    X=range(1,estimators_num+1)
    ax.plot(list(X),list(clf.staged_score(X_train,y_train)),label="Traing score")
    ax.plot(list(X),list(clf.staged_score(X_test,y_test)),label="Testing score")
    ax.set_xlabel("estimator num")
    ax.set_ylabel("score")
    ax.legend(loc="best")
    ax.set_title("AdaBoostClassifier")
    plt.show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号