Added modeling section
This commit is contained in:
@@ -41,8 +41,8 @@ def main():
|
||||
# evaluation
|
||||
le = get_label_encoder(df_clean)
|
||||
# draw_feature_importance(model, X)
|
||||
draw_confusion_matrix(y_test, y_pred, le)
|
||||
draw_classification_report(y_test, y_pred, le)
|
||||
# draw_confusion_matrix(y_test, y_pred, le)
|
||||
# draw_classification_report(y_test, y_pred, le)
|
||||
evaluate_accuracy(y_test, y_pred)
|
||||
|
||||
def evaluate_accuracy(y_test, y_pred):
|
||||
@@ -134,12 +134,9 @@ def draw_feature_importance(model, X):
|
||||
plt.show()
|
||||
|
||||
def train_logistic_regression(X_train, y_train):
|
||||
model = LogisticRegression(
|
||||
solver='lbfgs',
|
||||
max_iter=10000
|
||||
)
|
||||
model = LogisticRegression()
|
||||
model.fit(X_train, y_train)
|
||||
return model
|
||||
return model
|
||||
|
||||
def load_data():
|
||||
df = pd.read_csv(data_path, encoding="ascii", delimiter=",")
|
||||
|
||||
@@ -29,12 +29,14 @@ The target variable is the **stress level**, indicated as *low*, *moderate* or *
|
||||
**Figures:**
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
---
|
||||
|
||||
@@ -54,5 +56,8 @@ To improve model performance and reduce redundancy, I performed feature engineer
|
||||
- **GPA** was removed because it was highly correlated with **study time**, reducing redundant information and potential multicollinearity.
|
||||
- Features such as **extracurricular activity time** and **social time** were removed due to low predictive importance, minimizing noise and helping the model focus on the most relevant factors.
|
||||
|
||||

|
||||

|
||||
---
|
||||
|
||||
## Modeling
|
||||
|
||||
This model was made using **logistic regression**, it works well in this situation because it models the probability of each class based on the input features, making it effective for categorical outcomes. After experimenting with different hyperparameter settings, including various solvers and iteration limits, I found that removing them entirely did not noticeably change the model's performance, indicating that the default configuration worked well enough for this purpose.
|
||||
Reference in New Issue
Block a user