【发布时间】:2021-04-16 17:34:09
【问题描述】:
我想计算我的新值占原始值的百分比。 我想收到的是我的 Pandas DataFrame 中的新列。
我的 DataFrame 如下所示:
Feature Precision Accuracy Recall Specificity F1 score
0 original 0.949367 0.911765 0.9375 0.818182 0.943396
1 new_feat1 0.949367 0.911765 0.9375 0.818182 0.943396
2 new_feat2 0.950617 0.931373 0.9625 0.818182 0.956522
期望的结果如下所示:
Feature Precision Accuracy Recall Specificity F1 score Precision% Accuracy% Recall% Specificity% F1 score%
0 original 0.949367 0.911765 0.9375 0.818182 0.943396 100 100 100 100 100
1 new_feat1 0.949367 0.911765 0.9375 0.818182 0.943396 xxxxxx xxxxxx xxxxx xxxxxx xxxxxx
2 new_feat2 0.950617 0.931373 0.9625 0.818182 0.956522
计算so应该是这样的:
对于 new_feat1:
- precision% = new_feat1_precision * 100 / original_precision
- accuracy% = new_feat1_accuracy * 100 / original_accuracy
- 等等
或者如果它更容易,因为它建议 Dataframe 可以有这种格式
original new_feat1 new_feat2
Precision 0.949367 0.950617 0.95122
Accuracy 0.911765 0.931373 0.941176
Recall 0.9375 0.9625 0.975
Specificity 0.818182 0.818182 0.818182
F1 score 0.943396 0.956522 0.962963
那么想要的输出是:
original new_feat1 new_feat2
Precision 0.949367 0.950617 0.95122
Accuracy 0.911765 0.931373 0.941176
Recall 0.9375 0.9625 0.975
Specificity 0.818182 0.818182 0.818182
F1 score 0.943396 0.956522 0.962963
%Accuracy 100 xxxx xxxx
【问题讨论】: