开始使用免费开始使用

多变量逻辑回归

通常,您不会只用 loan_int_rate 来预测违约概率。您会希望利用手头所有数据来进行预测。

基于此,请尝试使用 cr_loan_clean 数据中的不同列(即特征)来训练一个新模型。这个模型会与第一个不同吗?为此,您可以直接查看逻辑回归的 .intercept_。请记住,它是函数的 y 截距,也是整体「不违约」的对数几率。

cr_loan_clean 数据以及之前的模型 clf_logistic_single 已加载到工作区。

本练习是课程的一部分

Python 信用风险建模

查看课程

练习说明

  • loan_int_rateperson_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(____.____)
编辑并运行代码