复习笔记2——线性回归、决策树、聚类

复习笔记2——线性回归、决策树、聚类

一、.线性回归

fit_intercept : 布尔型参数,表示是否计算该模型截距。可选参数。
normalize : 布尔型参数,若为True,则X在回归前进行归一化。可选参数。默认值为False。
copy_X : 布尔型参数,若为True,则X将被复制;否则将被覆盖。 可选参数。默认值为True。
n_jobs : 整型参数,表示用于计算的作业数量;若为-1,则用所有的CPU。可选参数。默认为1
positive=False#当设置为'True'时,强制系数为正。这选项仅支持密集阵列。

rint(model.coef_)#打印线性方程中的w
print(model.intercept_)#打印w0 就是线性方程中的截距b
3.sklearn.metrics

模块包括评分函数、性能指标和成对度量和距离计算。
F1-score: 2*(P*R)/(P+R)。参考《sklearn中 F1-micro 与 F1-macro区别和计算原理》
导入:from sklearn import metrics
分类指标

accuracy_score(y_true, y_pre)#精度

log_loss(y_true, y_pred, eps=1e-15, normalize=True, sample_weight=None, labels=None)交叉熵损失函数

auc(x, y, reorder=False)
ROC曲线下的面积;较大的AUC代表了较好的performance。
AUC:roc_auc_score(y_true, y_score, average=‘macro’, sample_weight=None)

f1_score(y_true, y_pred, labels=None, pos_label=1, average=‘binary’, sample_weight=None) F1值
	
precision_score(y_true, y_pred, labels=None, pos_label=1, average=‘binary’,) 查准率

recall_score(y_true, y_pred, labels=None, pos_label=1, average=‘binary’, sample_weight=None) 查全率
roc_curve(y_true, y_score, pos_label=None, sample_weight=None, drop_intermediate=True)
计算ROC曲线的横纵坐标值,TPR,FPR
TPR = TP/(TP+FN) = recall(真正例率,敏感度)
FPR = FP/(FP+TN)(假正例率,1-特异性)

classification_report(y_true, y_pred)#分类结果分析汇总

f1_score中关于参数average的用法描述:
‘micro’:Calculate metrics globally by counting the total true positives, false negatives and false positives.

‘micro’:通过先计算总体的TP,FN和FP的数量,再计算F1

‘macro’:Calculate metrics for each label, and find their unweighted mean. This does not take label imbalance into account.

‘macro’:分布计算每个类别的F1,然后做平均(各类别F1的权重相同)
回归指标

explained_variance_sc
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值