LR工具:
from sklearn.linear_model.logistic import LogisticRegression
常用方法:
fit(X, y, sample_weight=None)
fit_transform(X, y=None, **fit_params)
predict(X),用来预测样本,也就是分类 predict_proba(X),输出分类概率。返回每种类别的概率,按照分类类别顺序给出。
score(X, y, sample_weight=None),返回给定测试集合的平均准确率(mean accuracy)
模型参数配置:
model = LogisticRegression(max_iter=100,
verbose=True,
random_state=33,
tol=1e-4 )
model.fit(X_train, y_train)
predict = model.predict_proba(test)[:, 1]
test['Attrition']=predict # 转化为二分类输出
test['Attrition']=test['Attrition'].map(lambda x:1 if x>=0.5 else 0)
test[['Attrition']].to_csv('submit_lr.csv')