반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- discrete_scatter
- web 용어
- 자료구조
- broscoding
- web 사진
- 웹 용어
- inorder
- vscode
- C언어
- KNeighborsClassifier
- tensorflow
- java역사
- bccard
- 데이터전문기관
- web
- postorder
- 재귀함수
- mglearn
- pycharm
- 대이터
- cudnn
- paragraph
- web 개발
- Keras
- classification
- html
- 결합전문기관
- CES 2O21 참가
- CES 2O21 참여
- 머신러닝
Archives
- Today
- Total
bro's coding
머신러닝.sigmoid function 적용 본문
반응형
https://broscoding.tistory.com/114
https://broscoding.tistory.com/115
# data 준비
X=iris.data[:,[2]]
y=iris.target
# y==0 아닌 것은 전부 1(1대 다)
y[y==2]=1
plt.scatter(X[:,0],y,c=y,s=30)
plt.colorbar()
def sigmoid(x):
return 1/(1+np.exp(-x))
from sklearn.linear_model import LogisticRegression
C=10
model=LogisticRegression(C=C)
model.fit(X,y)
display(model.score(X,y),model.coef_,model.intercept_)
plt.figure(figsize=[10,8])
plt.scatter(X[:,0],y,c=y,s=30)
plt.colorbar()
from sklearn.linear_model import LogisticRegression
C=10
model=LogisticRegression(C=C)
model.fit(X,y)
display(model.score(X,y),model.coef_,model.intercept_)
plt.figure(figsize=[10,8])
plt.scatter(X[:,0],y,c=y,s=30)
plt.colorbar()
rng=np.arange(1,7,0.1)
plt.plot(rng,model.coef_[0]*rng+model.intercept_)
plt.plot(rng,sigmoid(model.coef_[0]*rng+model.intercept_),'r:')
plt.vlines([-model.intercept_[0]/model.coef_[0,0]],0,1,linestyles='dotted')
plt.ylim(-1,1.5)
plt.hlines([0],1,7,linestyles='dashed',alpha=0.3)
plt.text(3,0.5,'boundary=%.3f'%(-model.intercept_[0]/model.coef_[0,0]))
plt.title('LogisticRegression (C=%f)'%C)
# 1.0
# array([[3.16009911]])
# array([-8.16122736])
# 경계값 = -model.intercept_/model.coef_
반응형
'[AI] > python.sklearn' 카테고리의 다른 글
머신러닝.Linear SVM(선형 서포트벡터머신) 기초 (0) | 2020.04.14 |
---|---|
머신러닝.크로스 엔트로피 (0) | 2020.04.13 |
머신러닝.soft max (0) | 2020.04.13 |
머신러닝.sigmoid function(3D) (0) | 2020.04.13 |
머신러닝.linear_model.LogisticRegression(Class=4)(iris) (0) | 2020.04.13 |
머신러닝.LogisticRegression.C option 변화 관찰 (0) | 2020.04.13 |
sklearn.linear_model.LogisticRegression(Class=3) (0) | 2020.04.13 |
sklearn.LogisticRegression.predict_proba (0) | 2020.04.13 |
Comments