Re: [머신러닝/딥러닝 도서 Q&A] [혼공머신]p162

18 views
Skip to first unread message

Haesun Park

unread,
Aug 15, 2021, 11:22:14 PM8/15/21
to Ohyel, 머신러닝/딥러닝 도서 Q&A
안녕하세요. 박해선입니다.

for 반복문을 두 번 이상 실행하면 
train_score와 test_score 리스트에 계속 원소가 추가되기 때문입니다.
for 반복문 앞에 다음 코드를 넣어주세요.

train_score = []
test_score = []

감사합니다.

2021년 8월 16일 (월) 오전 11:45, Ohyel <inuy...@gmail.com>님이 작성:
alpha_list = [0.001, 0.01, 0.1, 1, 10, 100]
for alpha in alpha_list:
  ridge = Ridge(alpha=alpha)
  ridge.fit(train_scaled, train_target)
  train_score.append(ridge.score(train_scaled, train_target))
  test_score.append(ridge.score(test_scaled, test_target))
plt.plot(np.log10(alpha_list), train_score)
plt.plot(np.log10(alpha_list), test_score)
plt.xlabel('alpha')
plt.ylabel('R^2')
이 코드를 입력하고, 이 코드가 적힌 셀만 실행하면 
ValueError: x and y must have same first dimension, but have shapes (6,) and (12,) 
오류가 나고 ctrl + F9로 모든 셀을 실행시키면 또 잘 실행되네요
왜 그런건가요?

--
이 메일은 Google 그룹스 '머신러닝/딥러닝 도서 Q&A' 그룹에 가입한 분들에게 전송되는 메시지입니다.
이 그룹에서 탈퇴하고 더 이상 이메일을 받지 않으려면 ml-dl-book-qn...@googlegroups.com에 이메일을 보내세요.
웹에서 이 토론을 보려면 https://groups.google.com/d/msgid/ml-dl-book-qna/dfac8200-9d6b-4745-8c3a-2e2a8f57d4bcn%40googlegroups.com을(를) 방문하세요.
Reply all
Reply to author
Forward
0 new messages