다른 변수 조합 사용하기
로지스틱 회귀 모델에 변수를 더 추가해 복잡도를 높인다고 해서 자동으로 더 정확한 모델이 되지는 않습니다. 이 연습 문제에서는 변수 3개를 추가했을 때 모델이 더 정확해지는지 확인해 보세요.
variables_1과 variables_2가 환경에 준비되어 있습니다. 콘솔에 출력해 보고 어떤 변수들이 들어 있는지 살펴보세요.
이 연습은 강의의 일부입니다
Python으로 배우는 예측 분석 입문
연습 안내
variables_1에 비해 변수 3개가 추가된variables_2를 사용해logreg모델을 학습하세요.- 이 모델로 예측을 생성하세요.
- 이 모델의 AUC를 계산하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Create appropriate DataFrames
X_1 = basetable[variables_1]
X_2 = basetable[variables_2]
y = basetable[["target"]]
# Create the logistic regression model
logreg = linear_model.LogisticRegression()
# Make predictions using the first set of variables and assign the AUC to auc_1
logreg.fit(X_1, y)
predictions_1 = logreg.predict_proba(X_1)[:,1]
auc_1 = roc_auc_score(y, predictions_1)
# Make predictions using the second set of variables and assign the AUC to auc_2
logreg.____(____, ____)
predictions_2 = ____.____(____)[____,____]
auc_2 = ____(____, ____)
# Print auc_1 and auc_2
print(round(auc_1,2))
print(round(auc_2,2))