
分类
|
189
相应的
Python
代码如下:
print('percentage of loans in default: ',
100 * np.mean(full_train_set.outcome == 'default'))
如果使用完整的数据集来训练模型,会是什么情况呢?使用
R
代码看一下:
full_model <- glm(outcome ~ payment_inc_ratio + purpose_ + home_ +
emp_len_+ dti + revol_bal + revol_util,
data=full_train_set, family='binomial')
pred <- predict(full_model)
mean(pred > 0)
[1] 0.003942094
Python
代码如下:
predictors = ['payment_inc_ratio', 'purpose_', 'home_', 'emp_len_',
'dti', 'revol_bal', 'revol_util']
outcome = 'outcome'
X = pd.get_dummies(full_train_set[predictors], prefix='', prefix_sep='',
drop_first=True)
y = full_train_set[outcome]
full_model = LogisticRegression(penalty='l2', C=1e42, ...