多类记分器计算库。

scorer的Python项目详细描述


AuthorsProjectBuild StatusLicenseCode QualityCoverage
N. CurtiScorerLinux/MacOS : travisWindows : appveyorlicenseCodacy : CodacyCodebeat : CODEBEATcodecov

Scorer++ CI

Scorer CI

GitHub pull-requestsGitHub issues

GitHub starsGitHub watchers

机器学习成绩

使用c++支持和网络依赖性优化和扩展PyCM库。在

  1. Getting Started
  2. Prerequisites
  3. Usage
  4. License
  5. Contribution
  6. Authors
  7. Acknowledgments
  8. Citation

入门

要构建项目,可以使用MakefileCMake(推荐)。在

在第一种情况下,您可以看到整个可用规则集,只需键入makemake example来用c++构建example脚本,或者make pythonic来构建代码的Cython版本。在

构建脚本(build.shbuild.ps1)允许在Windows和Linux/MacOS系统中使用CMake自动构建完整的库。在

git clone https://github.com/Nico-Curti/scorer.git
cd scorer
./build.sh

对于Python版本的手动安装,还可以将setup脚本作为

^{pr2}$

或者对开发者来说

python -m pip install -r requirements.txt
python setup.py develop --user

如果您在没有root权限的情况下工作,我们建议您使用^{}脚本轻松安装所有必需的依赖项。在

先决条件

要构建c++版本的代码,至少需要c++14。 C++支持编译器:

gcc version

clang version

msvc version

支持的Python版本:

Python version

如果安装了OMP,则代码的OMP版本将自动可用,这样所有度量计算都将根据生成的依赖关系图并行执行。在

Python版本的先决条件的完整列表列在requirements中。在

Note:如果您对依赖关系图的可视化和其他一些管理已评估度量的实用程序感兴趣,可以在utils文件夹中找到所有脚本。 在这种情况下,还需要安装以下Python包:

networkx>=2.2
pandas>=0.23.3
matplotlib>=2.2.2
mpld3>=0.3

使用

您可以在带有scorer.h头文件的简单include的c++项目中使用这些库,也可以在Python应用程序中使用这些库,其中scorer类被包装起来以提供一个简单的字典作为回报。在

如果使用c++版本,请注意并行环境(在运行分数计算之前打开并行区域,如下面的示例代码所示)。在

#include<array>#include<scorer.h>intmain(){constintn_labels=12;std::array<int,n_labels>y_true={{2,0,2,2,0,1,1,2,2,0,1,2}};std::array<int,n_labels>y_pred={{0,0,2,1,0,2,1,0,2,0,2,2}};scorerscore;#ifdef _OPENMP#pragma omp parallel shared (score){#endifscore.compute_score(y_true.data(),y_pred.data(),n_labels,n_labels);#ifdef _OPENMP}#endifscore.print();return0;}

相同的代码可以用Python重写(也可以使用不同的标签dtype),如下所示

#import numpy as npfromscorerimportScorery_true=['a','b','a','a','b','c','c','a','a','b','c','a']# np.array([2, 0, 2, 2, 0, 1, 1, 2, 2, 0, 1, 2], dtype=np.int32)y_pred=['b','b','a','c','b','a','c','b','a','b','a','a']# np.array([0, 0, 2, 1, 0, 2, 1, 0, 2, 0, 2, 2], dtype=np.int32)scorer=Scorer()scorer.evaluate(y_true,y_pred)print(scorer)

两次执行的输出都是一样的,应该是这样的

$ python ./scorer/example/main.py
Classes: 0, 1, 2
Confusion Matrix:
 3.0 0.0 0.0
 0.0 1.0 2.0
 2.0 1.0 3.0

Class Statistics:

TP(True positive/hit)3.000                1.000                3.000
FN(False negative/miss/type 2 error)0.000                2.000                3.000
FP(False positive/type 1 error/false alarm)2.000                1.000                2.000
TN(True negative/correct rejection)7.000                8.000                4.000
POP(Population)12.000               12.000               12.000
P(Condition positive or support)3.000                3.000                6.000
N(Condition negative)9.000                9.000                6.000
TOP(Test outcome positive)5.000                2.000                5.000
TON(Test outcome negative)7.000               10.000                7.000
TPR(Sensitivity / recall / hit rate / true positive rate)1.000                0.333                0.500
TNR(Specificity or true negative rate)0.778                0.889                0.667
PPV(Precision or positive predictive value)0.600                0.500                0.600
NPV(Negative predictive value)1.000                0.800                0.571
FNR(Miss rate or false negative rate)0.000                0.667                0.500
FPR(Fall-out or false positive rate)0.222                0.111                0.333
FDR(False discovery rate)0.400                0.500                0.400
FOR(False omission rate)0.000                0.200                0.429
ACC(Accuracy)0.833                0.750                0.583
F1(F1 score - harmonic mean of precision and sensitivity)0.750                0.400                0.545
F0.5(F0.5 score)0.652                0.455                0.577
F2(F2 score)0.882                0.357                0.517
MCC(Matthews correlation coefficient)0.683                0.258                0.169
BM(Informedness or bookmaker informedness)0.778                0.222                0.167
MK(Markedness)0.600                0.300                0.171
PLR(Positive likelihood ratio)4.500                3.000                1.500
NLR(Negative likelihood ratio)0.000                0.750                0.750
DOR(Diagnostic odds ratio)                                                                        inf                4.000                2.000
PRE(Prevalence)0.250                0.250                0.500
G(G-measure geometric mean of precision and sensitivity)0.775                0.408                0.548
RACC(Random accuracy)0.104                0.042                0.208
ERR(Error rate)0.167                0.250                0.417
RACCU(Random accuracy unbiased)0.111                0.043                0.210
J(Jaccard index)0.600                0.250                0.375
IS(Information score)1.263                1.000                0.263
CEN(Confusion entropy)0.250                0.497                0.604
MCEN(Modified confusion entropy)0.264                0.500                0.688
AUC(Area Under the ROC curve)0.889                0.611                0.583
dInd(Distance index)0.222                0.676                0.601
sInd(Similarity index)0.843                0.522                0.575
DP(Discriminant power)                                                                            inf                0.332                0.166
Y(Youden index)0.778                0.222                0.167
PLRI(Positive likelihood ratio interpretation)                                                   Poor                 Poor                 Poor
NLRI(Negative likelihood ratio interpretation)                                                   Good           Negligible           Negligible
DPI(Discriminant power interpretation)                                                           None                 Poor                 Poor
AUCI(AUC value interpretation)                                                              Very Good                 Fair                 Poor
GI(Gini index)0.778                0.222                0.167
LS(Lift score)2.400                2.000                1.200
AM(Difference between automatic and manual classification)2.000               -1.000               -1.000
OP(Optimized precision)0.708                0.295                0.440
IBA(Index of balanced accuracy)0.951                0.132                0.278
GM(G-mean geometric mean of specificity and sensitivity)0.882                0.544                0.577
Q(Yule Q - coefficient of colligation)                                                            nan                0.600                0.333
AGM(Adjusted geometric mean)0.837                0.692                0.607
MCCI(Matthews correlation coefficient interpretation)                                        Moderate           Negligible           Negligible
AGF(Adjusted F-score)0.914                0.540                0.552
OC(Overlap coefficient)1.000                0.500                0.600
OOC(Otsuka-Ochiai coefficient)0.775                0.408                0.548
AUPR(Area under the PR curve)0.800                0.417                0.550
BCD(Bray-Curtis dissimilarity)0.083                0.042                0.042
ICSI(Individual classification success index)0.600               -0.167                0.100

Overall Statistics:

Overall ACC                                                                      0.583
Overall RACCU                                                                    0.365
Overall RACC                                                                     0.354
Kappa                                                                            0.355
Scott PI                                                                         0.344
Get AC1                                                                          0.389
Bennett S                                                                        0.375
Kappa Standard Error                                                             0.220
Kappa Unbiased                                                                   0.344
Kappa No Prevalence                                                              0.167
Kappa 95% CI                                                                     (0.7867531180381775, -0.0770757719874382)
Standard Error                                                                   0.142
95% CI                                                                           (0.8622781038284302, 0.30438855290412903)
Chi-Squared                                                                      6.600
Phi-Squared                                                                      0.550
Cramer V                                                                         0.524
Response Entropy                                                                 1.483
Reference Entropy                                                                1.500
Cross Entropy                                                                    1.594
Joint Entropy                                                                    2.459
Conditional Entropy                                                              0.959
Mutual Information                                                               0.524
KL Divergence                                                                    0.094
Lambda B                                                                         0.429
Lambda A                                                                         0.167
Chi-Squared DF                                                                   4.000
Overall J                                                                        (1.225000023841858, 0.40833333134651184)
Hamming loss                                                                     0.417
Zero-one Loss                                                                    5.000
NIR                                                                              0.500
P-value                                                                          0.387
Overall CEN                                                                      0.464
Overall MCEN                                                                     0.519
Overall MCC                                                                      0.367
RR                                                                               4.000
CBA                                                                              0.478
AUNU                                                                             0.694
AUNP                                                                             0.667
RCI                                                                              0.349
Pearson C                                                                        0.596
F1 Micro                                                                         0.583
PPV Micro                                                                        0.583
TPR Micro                                                                        0.583
SOA1(Landis & Koch)                                                              Fair
SOA2(Fleiss)                                                                     Poor
SOA3(Altman)                                                                     Fair
SOA4(Cicchetti)                                                                  Poor
SOA5(Cramer)                                                                     Relatively Strong
SOA6(Matthews)                                                                   Weak
ACC Macro                                                                        0.722
F1 Macro                                                                         0.565
TPR Macro                                                                        0.611
PPV Macro                                                                        0.567
CSI                                                                              0.178

如果你使用非整数标签,记分器对象提供有用的^ {< CD5>}(^ {CD6>} C++)函数。 在C++中必须使用它,因为函数签名只需要整数(int32)值,Python版本会根据要求自动对标签进行编码/解码。在

utils文件夹中报告了一些实用程序脚本。 make_script.py允许用c++编写scorer类的完整并行版本。 通过这种方式,如果您向库中添加一个新的运算符,您可以运行此代码来更新scorer类并行化策略(在dependency_graphs.py脚本中计算)。在

使用view_stats.py您可以看到完整的计算统计图,并支持HTML以获得更愉快的视觉效果(例如graph

NOTE:使用view_stats.py可以找到错误

ObjectoftypendarrayisnotJSONserializable

我建议使用以下命令来解决这个mpld3问题:

python -m pip install --user "git+https://github.com/javadba/mpld3@display_fix"

关于score函数及其含义的完整信息列表可以在原始PyCM项目的惊人的documentation中找到。在

许可证

Scorer软件包是根据麻省理工学院的“Expat”许可证授权的。License

贡献

任何贡献都是非常受欢迎的:心脏:。只需填写issuepull request,我们将尽快检查!在

请参阅here以获取有关如何参与此项目的更多信息。在

作者

另请参阅参与该项目的contributorsGitHub contributors的列表。在

致谢

感谢本项目的所有贡献者:

^{tb2}$

引文

如果您发现{}对您的研究有帮助,请考虑引用该项目

@misc{Scorer,
  author = {Nico Curti},
  title = {Scorer},
  year = {2019},
  publisher = {GitHub},
  howpublished = {\url{https://github.com/Nico-Curti/scorer}},
}

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何使用nextLine()方法   java如何在使用Lombok@Slf4j时使其他依赖项的日志静音   java JUnit在升级到Spring boot 2.3后失败   java JTextArea在JFrame边界处截断   面板的java坐标规范   java给定两个数字,如果其中任何一个除以另一个,则返回true,否则返回false   java如何使log4jdk日志适配器打印JUL级别?   java Spring MVC 3:MVC上下文中控制器上的AOP不工作   JavaAxis2。AxisFault:[clientAuthRequired]未找到客户端证书   java Android。apk根据自v17工具以来用于部署的dev box将大小增加一倍   java如何跨包为多个存储库集中一个配置?   Java Maven Mojo:复杂映射属性   java如何使用@InjectMocks注入相同类型的依赖项?   java在不重复class属性的情况下(通过XML)配置Springbean   文件中不生成java日志   多线程使用Java在循环内并行执行该方法   java调用自定义Apache Velocity事件处理程序错误   如何在Java中解码用GSON创建的JSON文件?   SQLite数据库中的java大字符串