다중 클래스 로지스틱 회귀 적합하기
이 연습에서는 손글씨 숫자 데이터셋에 대해 two types of multi-class logistic regression인 one-vs-rest와 softmax/multinomial을 학습시키고 결과를 비교해 볼 거예요. 손글씨 숫자 데이터셋은 이미 X_train, y_train, X_test, y_test로 로드되어 분할되어 있어요.
이 연습은 강의의 일부입니다
Python으로 배우는 선형 분류기
연습 안내
multi_class매개변수를 설정해 one-vs-rest 로지스틱 회귀 분류기를 학습하고 결과를 보고하세요.multi_class매개변수를 설정해 다항(multinomial) 로지스틱 회귀 분류기를 학습하고 결과를 보고하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Fit one-vs-rest logistic regression classifier
lr_ovr = ____
lr_ovr.fit(X_train, y_train)
print("OVR training accuracy:", lr_ovr.score(X_train, y_train))
print("OVR test accuracy :", lr_ovr.score(X_test, y_test))
# Fit softmax classifier
lr_mn = ____
lr_mn.fit(X_train, y_train)
print("Softmax training accuracy:", lr_mn.score(X_train, y_train))
print("Softmax test accuracy :", lr_mn.score(X_test, y_test))