
172
|
第
5
章
purpose_major_purchase purpose_medical
0.22963 0.51048
purpose_other purpose_small_business
0.62066 1.21526
home_OWN home_RENT
0.04833 0.15732
emp_len_ > 1 Year borrower_score
-0.35673 -4.61264
Degrees of Freedom: 45341 Total (i.e. Null); 45330 Residual
Null Deviance: 62860
Residual Deviance: 57510 AIC: 57540
响应变量是
outcome
,为
0
时表示贷款已还清,为
1
时表示贷款违约。
purpose_
和
home_
是因子变量,分别表示贷款目的和房屋所有权状态。和线性回归一样,有
P
个水平的因
子变量用
P
–1
个列表示
。在
R
中,默认使用
参照
编码,其他水平都是与参照水平进行比
较的(参见
4.4
节)
。这两个因子变量的参照水平分别是
credit_card
和
MORTGAGE
。变量
borrower_score
是一个介于
0
和
1
之间的分数,表示借款者的信誉评级(从糟糕到极好)。
这个变量是使用
K
最近邻方法根据其他几个变量创建出来的,参见
6.1.6
节。
在
Python
中
,可以使用
scikit-learn
中的
LogisticRegression
类,它属于
sklearn.
linear_model
模块。参数 ...