WGU D600 Task 2: Logistic Regression
Analysis | Complete Report, Python
Modeling, Confusion Matrix & Results |
2026/2027 Updated
TASK 2: LOGISTIC REGRESSION – COMPLETE
REPORT TEMPLATE
A. RESEARCH QUESTION – PURPOSE
Research Question: Can logistic regression
accurately predict binary categorical outcome using
numerical and categorical predictors?
Goal: Build, evaluate, and interpret logistic
regression model – Address class imbalance, feature
scaling, encoding, feature selection, performance
metrics – Provide Python code, confusion matrix,
ROC-AUC, classification report – Compare to
baseline
Example Dataset: Use your assigned WGU D600
Task 2 dataset – e.g., Churn, Diabetes, Loan Default,
,Attrition – Example here uses Telco Churn – Target
Churn Yes/No – 7043 rows – 21 features – Replace
with your actual D600 file – Same workflow applies
Variables:
• Independent – Numerical – tenure,
MonthlyCharges, TotalCharges – Categorical –
Contract, InternetService, PaymentMethod
• Dependent binary – Churn – 0 No, 1 Yes – Or
Diabetes 0/1, Default 0/1
B. DATA PREPARATION – PYTHON – FULL CODE
Step 1: Import Libraries
Python
import pandas as pdimport numpy as npimport
matplotlib.pyplot as pltimport seaborn as snsfrom
sklearn.model_selection import train_test_split
16 lines hidden
Step 2: EDA – Class Imbalance – Why It Matters
Python
, # Class distribution – Imbalance
checkplt.figure(figsize=(6,4))sns.countplot(x='Churn'
, data=df)plt.title('Class Distribution – Churn – Check
Imbalance')plt.show()
12 lines hidden
Step 3: Data Cleaning – Handling Missing,
Conversion
Python
# Example – TotalCharges object with spaces –
Convert to numericdf['TotalCharges'] =
pd.to_numeric(df['TotalCharges'],
errors='coerce')df['TotalCharges'].fillna(df['TotalChar
ges'].median(), inplace=True)# Drop ID column –
e.g., customerID not predictive
12 lines hidden
Step 4: Train Test Split – Stratified – Scale – Encode
Python
Analysis | Complete Report, Python
Modeling, Confusion Matrix & Results |
2026/2027 Updated
TASK 2: LOGISTIC REGRESSION – COMPLETE
REPORT TEMPLATE
A. RESEARCH QUESTION – PURPOSE
Research Question: Can logistic regression
accurately predict binary categorical outcome using
numerical and categorical predictors?
Goal: Build, evaluate, and interpret logistic
regression model – Address class imbalance, feature
scaling, encoding, feature selection, performance
metrics – Provide Python code, confusion matrix,
ROC-AUC, classification report – Compare to
baseline
Example Dataset: Use your assigned WGU D600
Task 2 dataset – e.g., Churn, Diabetes, Loan Default,
,Attrition – Example here uses Telco Churn – Target
Churn Yes/No – 7043 rows – 21 features – Replace
with your actual D600 file – Same workflow applies
Variables:
• Independent – Numerical – tenure,
MonthlyCharges, TotalCharges – Categorical –
Contract, InternetService, PaymentMethod
• Dependent binary – Churn – 0 No, 1 Yes – Or
Diabetes 0/1, Default 0/1
B. DATA PREPARATION – PYTHON – FULL CODE
Step 1: Import Libraries
Python
import pandas as pdimport numpy as npimport
matplotlib.pyplot as pltimport seaborn as snsfrom
sklearn.model_selection import train_test_split
16 lines hidden
Step 2: EDA – Class Imbalance – Why It Matters
Python
, # Class distribution – Imbalance
checkplt.figure(figsize=(6,4))sns.countplot(x='Churn'
, data=df)plt.title('Class Distribution – Churn – Check
Imbalance')plt.show()
12 lines hidden
Step 3: Data Cleaning – Handling Missing,
Conversion
Python
# Example – TotalCharges object with spaces –
Convert to numericdf['TotalCharges'] =
pd.to_numeric(df['TotalCharges'],
errors='coerce')df['TotalCharges'].fillna(df['TotalChar
ges'].median(), inplace=True)# Drop ID column –
e.g., customerID not predictive
12 lines hidden
Step 4: Train Test Split – Stratified – Scale – Encode
Python