多分类损失函数和评价指标(objectives and metrics)

目录

1 多分类损失函数和评价指标(objectives and metrics) 1
1.1 MultiClass- softmax loss 2
1.2 MultiClassOneVsAll 2
1.3 Precision 3
1.4 Recall 3
1.5 F-Measure F1 3
1.6 TotalF1 3
1.6.1 Weighted TotalF1 3
1.6.2 Macro F1 4
1.6.3 Micro F1 4
1.7 MCC 4
1.8 Accuracy 5
1.9 ZeroOneLoss 5
1.10 HingeLoss 5
1.11 HammingLoss 5
1.12 Kappa 6
1.13 WKappa 6
1.14 AUC 6

1 多分类损失函数和评价指标(objectives and metrics)

1.1 MultiClass- softmax loss

在这里插入图片描述

其中w是样本数据的权重。

1.2 MultiClassOneVsAll

在one-vs-all策略中,假设有n个类别,那么就会建立n个二项分类器,每个分类器针对其中一个类别和剩余类别进行分类。进行预测时,利用这n个二项分类器进行分类,得到数据属于当前类的概率,选择其中概率最大的一个类别作为最终的预测结果。
在这里插入图片描述

1.3 Precision

在这里插入图片描述

1.4 Recall

在这里插入图片描述

1.5 F-Measure F1

在这里插入图片描述

1.6 TotalF1

1.6.1 Weighted TotalF1
在这里插入图片描述

1.6.2 Macro F1
在这里插入图片描述

1.6.3 Micro F1
在这里插入图片描述

1.7 MCC

马休斯相关系数(Matthews Correlation Coefficient )–MCC。它能解决不均衡类别数据的指标衡量问题
混淆矩阵(confusion matrix)衡量的是一个分类器分类的准确程度。
在这里插入图片描述

  • 当FP=FN=0即完全预测正确时 MCC=1
  • 当完全预测错误时MCC=-1,此时将标签逆转即可
  • 当MCC=0时表明模型不比随机预测好

1.8 Accuracy

1.9 ZeroOneLoss

1−Accuracy

1.10 HingeLoss

Hinge Loss是一种目标函数(或者说损失函数)的名称,通常被用于最大间隔算法(maximum-margin),而最大间隔算法又是SVM(支持向量机support vector machines)用到的重要算法。

1.11 HammingLoss

Hamming loss(汉明损失),该指标衡量了预测所得标记与样本实际标记之间的不一致程度,即样本具 有标记y但未被识别出,或不具有标记y却别误判的可能性。它直接统计了被误分类label的个数(不属于这个样本的标签被预测,或者属于这个样本的标签没有被预测)。hloss=0表示所有的每一个data的所有label都被分对了。
在这里插入图片描述

1.12 Kappa

Kappa是一种基于混淆矩阵计算的衡量分类精度的指标,通常kappa落在 [0-1] 间,可分为五组来表示不同级别的一致性:0-0.2为极低的一致性(slight)、0.21-0.4为一般的一致性(fair)、0.41-0.6为 中等的一致性(moderate)、0.61-0.8 为高度的一致性(substantial)和0.81-1几乎完全一致(almost perfect)。

1.13 WKappa

1.14 AUC

### MLXTEND FP-Growth Function Usage and Documentation The `mlxtend` library provides various tools for data science tasks including frequent pattern mining through its implementation of the FP-Growth algorithm. Below is detailed information on how one can use this functionality within mlxtend. #### Installation To begin working with the FP-Growth function provided by `mlxtend`, ensure that the package has been installed properly: ```bash pip install mlxtend ``` #### Importing Necessary Modules Import statements bring necessary components into your Python environment so they may be utilized effectively during coding sessions or projects involving transactional datasets where finding associations between items might prove beneficial. ```python from mlxtend.preprocessing import TransactionEncoder from mlxtend.frequent_patterns import fpgrowth, association_rules import pandas as pd ``` #### Preparing Data Data preparation involves converting raw input lists containing transactions (sets of item occurrences) into a binary format suitable for analysis via algorithms like FP-Growth which require such structured inputs. ```python dataset = [['Milk', 'Onion', 'Nutmeg', 'Kidney Beans', 'Eggs', 'Yogurt'], ['Dill', 'Onion', 'Nutmeg', 'Kidney Beans', 'Eggs', 'Yogurt'], ['Milk', 'Apple', 'Kidney Beans', 'Eggs'], ['Milk', 'Unicorn', 'Corn', 'Kidney Beans', 'Yogurt'], ['Corn', 'Onion', 'Onion', 'Kidney Beans', 'Ice cream', 'Eggs']] te = TransactionEncoder() te_ary = te.fit(dataset).transform(dataset) df = pd.DataFrame(te_ary, columns=te.columns_) print(df.head()) ``` This snippet transforms the dataset into a DataFrame representation ready for further processing steps. #### Applying FP-Growth Algorithm With prepared data at hand, invoking the actual FP-Growth method becomes straightforward; specifying parameters allows customization according to specific requirements regarding minimum support thresholds etc., ensuring results align closely enough with research objectives or business needs. ```python frequent_itemsets = fpgrowth(df, min_support=0.6, use_colnames=True) print(frequent_itemsets) ``` Here, setting `min_support=0.6` filters out less common combinations while retaining those appearing frequently across multiple records – adjusting this value impacts both computational efficiency and output comprehensiveness significantly depending upon context-specific constraints faced when conducting analyses similar in nature. #### Generating Association Rules After obtaining sets of commonly co-occurring elements, deriving actionable insights often entails generating rules linking antecedents towards consequent outcomes based off discovered patterns present throughout examined collections of entities under consideration here represented numerically inside matrices processed earlier. ```python rules = association_rules(frequent_itemsets, metric="lift", min_threshold=1.2) print(rules[['antecedents', 'consequents', 'support', 'confidence', 'lift']]) ``` By employing metrics such as lift alongside confidence levels exceeding predefined limits set forth previously (`min_threshold=1.2`), meaningful relationships emerge highlighting potential correlations worthy exploring deeper beyond surface-level observations alone possible otherwise without leveraging these advanced techniques offered freely thanks largely due contributions made available open source communities surrounding libraries like `mlxtend`.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AI强仔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值