반응형
Notice
Recent Posts
Recent Comments
Link
관리 메뉴

bro's coding

머신러닝.LogisticRegression.C option 변화 관찰 본문

[AI]/python.sklearn

머신러닝.LogisticRegression.C option 변화 관찰

givemebro 2020. 4. 13. 14:28
반응형

https://broscoding.tistory.com/132

 

머신러닝.linear_model.LogisticRegression(Class=3)

https://broscoding.tistory.com/128 머신러닝.datasets .make_blobs 사용하기 from sklearn.datasets import make_blobs X,y=make_blobs(400,2,[[0,0],[5,5]],[2,3]) # 400 : 행의 갯수 # 2 : 속성의 갯수 2개(축..

broscoding.tistory.com

C가 커질 수록 과적합 된다

C가 커질수록 세밀하게 나눠준다

1/C=a

c:(cost,lose,penalty)

for j in range(-5,5):
    from sklearn.linear_model import LogisticRegression
    model = LogisticRegression(C=1*(10**j))
    model.fit(X,y)
    import mglearn
    plt.figure(figsize=[10,8])
    mglearn.plots.plot_2d_classification(model,X,cm='Reds',alpha=0.3)
    mglearn.discrete_scatter(X[:,0],X[:,1],y,alpha=0.7)

    w=model.coef_
    b=model.intercept_

    rng=np.array([X[:,0].min(),X[:,0].max()])
    for i in range(3):
        plt.plot(rng,-(w[i,0]*rng+b[i])/w[i,1],':',lw=4,label='line'+str(i))
    plt.legend()
    plt.title('C='+str(1*(10**j)))

 

반응형
Comments