多变量逻辑回归
通常,您不会只用 loan_int_rate 来预测违约概率。您会希望利用手头所有数据来进行预测。
基于此,请尝试使用 cr_loan_clean 数据中的不同列(即特征)来训练一个新模型。这个模型会与第一个不同吗?为此,您可以直接查看逻辑回归的 .intercept_。请记住,它是函数的 y 截距,也是整体「不违约」的对数几率。
cr_loan_clean 数据以及之前的模型 clf_logistic_single 已加载到工作区。
本练习是课程的一部分
Python 信用风险建模
练习说明
- 用
loan_int_rate和person_emp_length创建新的X数据集,保存为X_multi。 - 用
loan_status创建y数据集。 - 基于新的
X数据创建并调用.fit()训练一个LogisticRegression()模型,保存为clf_logistic_multi。 - 打印模型的
.intercept_值
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Create X data for the model
X_multi = ____[[____,____]]
# Create a set of y data for training
y = ____[[____]]
# Create and train a new logistic regression
clf_logistic_multi = ____(solver='lbfgs').____(____, np.ravel(____))
# Print the intercept of the model
print(____.____)