반응형
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 | 29 | 30 |
Tags
- mglearn
- java역사
- vscode
- bccard
- paragraph
- CES 2O21 참여
- inorder
- 데이터전문기관
- web 개발
- postorder
- html
- Keras
- 웹 용어
- tensorflow
- classification
- C언어
- 결합전문기관
- web
- KNeighborsClassifier
- 재귀함수
- broscoding
- cudnn
- 머신러닝
- CES 2O21 참가
- 자료구조
- pycharm
- web 사진
- web 용어
- discrete_scatter
- 대이터
Archives
- Today
- Total
bro's coding
sklearn.linear_model.Lasso.alpha값에 따른 score변화 관찰 본문
반응형
alphas = [10, 1, 0.1, 0.01, 0.001, 0.0001]
train_scores = []
test_scores = []
ws = []
for alpha in alphas:
lasso = Lasso(alpha=alpha)
lasso.fit(X_train, y_train)
ws.append(lasso.coef_)
s1 = lasso.score(X_train, y_train)
s2 = lasso.score(X_test, y_test)
train_scores.append(s1)
test_scores.append(s2)
display(train_scores, test_scores, ws)
[0.0,
0.40725895623295394,
0.900745787336254,
0.9279631631543988,
0.9311666853919297,
0.9311995291582065]
[-0.015873329420263538,
0.38141259918310877,
0.8749239055051604,
0.9113752481323003,
0.9233208053315227,
0.9241299402555914]
[array([ 0., -0., 0., 0.]),
array([ 0. , -0. , 0.11292891, 0. ]),
array([ 0. , -0. , 0.405014, 0. ]),
array([-0.01103514, -0. , 0.2521542 , 0.45062708]),
array([-0.05652789, -0.05055522, 0.21445927, 0.58184325]),
array([-0.06075528, -0.0559519 , 0.21031884, 0.59543535])]
import matplotlib.pyplot as plt
import numpy as np
plt.plot(range(len(alphas)), train_scores)
plt.plot(range(len(alphas)), test_scores)
plt.plot(range(len(alphas)), 10*np.abs(np.array(ws)[:,0]), '--')
plt.xticks(range(len(alphas)),alphas)
plt.legend(['train', 'test', r'$ 10 \times \vert w_0 \vert $'],loc='lower right')
plt.title('Lasso scores for $\\alpha$\'s')
plt.xlabel('alpha')
반응형
'[AI] > python.sklearn' 카테고리의 다른 글
sklearn.install graphviz (0) | 2020.04.20 |
---|---|
sklearn.tree.DecisionTreeClassifier.max_depth 변화 관찰 (0) | 2020.04.20 |
sklearn.non-linear regression(비선형회귀) (0) | 2020.04.19 |
sklearn.linear_model.Ridge.alpha에 따른 회귀선 변화 관찰 (0) | 2020.04.19 |
sklearn.Compare Ridge and Rasso (0) | 2020.04.17 |
sklearn.SVM. C and gamma 변화 관찰 (0) | 2020.04.17 |
sklearn.svm.SVC.decision bounds (0) | 2020.04.17 |
sklearn.svm.SVC and normalization(breast cancer) (0) | 2020.04.16 |
Comments