โมเดลพื้นฐาน Logistic Regression สำหรับการจำแนกประเภท
ใน 2 บทที่ผ่านมา คุณได้เรียนรู้ว่าการเลือก feature มีคุณค่าเพียงใดในบริบทของการสัมภาษณ์งาน machine learning อีกชุดคำถามที่มักพบในการสัมภาษณ์คือเรื่อง feature engineering และวิธีที่ช่วยเพิ่มประสิทธิภาพของโมเดล
ในแบบฝึกหัดนี้ จะมีการสร้าง feature ใหม่จากชุดข้อมูล loan_data ของบทที่ 1 แล้วเปรียบเทียบคะแนนความแม่นยำของโมเดล Logistic Regression ก่อนและหลังการทำ feature engineering โดยเทียบ label จริงกับค่าที่โมเดลทำนายสำหรับตัวแปรเป้าหมาย Loan Status
ไลบรารีที่จำเป็นได้ถูก import ไว้ให้แล้ว ได้แก่ matplotlib.pyplot as plt, seaborn as sns, LogisticRegression จาก sklearn.linear_model, train_test_split จาก sklearn.model_selection, และ accuracy_score จาก sklearn.metrics
การทำ feature engineering ถือเป็นขั้นตอน การเตรียมข้อมูล (pre-processing) ก่อนการสร้างโมเดล:

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
ฝึกตอบคำถามสัมภาษณ์ Machine Learning ด้วย Python
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Create X matrix and y array
X = loan_data.____("____", axis=1)
y = loan_data["____"]
# Train/test split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=123)
# Instantiate
logistic = ____()
# Fit
logistic.____(____, ____)
# Predict and print accuracy
print(____(y_true=____, y_pred=logistic.____(____)))