Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
ffm-baseline
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ML
ffm-baseline
Commits
76fdbb84
Commit
76fdbb84
authored
Aug 07, 2018
by
张彦钊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete auc function matplotlib
parent
beb3b2e3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
10 deletions
+10
-10
aucCaculate.py
aucCaculate.py
+1
-1
rocCurve.py
eda/ml_tools/rocCurve.py
+9
-9
No files found.
aucCaculate.py
View file @
76fdbb84
...
...
@@ -7,4 +7,4 @@ if __name__ == "__main__":
test
=
pd
.
read_csv
(
DIRECTORY_PATH
+
"test.csv"
,
header
=
None
)
test_label
=
test
[
0
]
.
apply
(
lambda
x
:
x
[
0
])
.
values
predict
=
pd
.
read_csv
(
DIRECTORY_PATH
+
"model.out"
,
header
=
None
)[
0
]
.
values
get_roc_curve
(
test_label
,
predict
,
DIRECTORY_PATH
+
"auc_test.JPG"
)
get_roc_curve
(
test_label
,
predict
)
eda/ml_tools/rocCurve.py
View file @
76fdbb84
import
pandas
as
pd
from
sklearn
import
metrics
import
matplotlib.pyplot
as
plt
#
import matplotlib.pyplot as plt
from
sklearn.metrics
import
auc
import
argparse
...
...
@@ -12,7 +12,7 @@ parser.add_argument('output_photo',help='The filename of the output_photo')
args
=
parser
.
parse_args
()
def
get_roc_curve
(
label
,
pred
,
output
):
def
get_roc_curve
(
label
,
pred
):
"""
计算二分类问题的roc和auc
"""
...
...
@@ -24,15 +24,15 @@ def get_roc_curve(label,pred,output):
fpr
,
tpr
,
thresholds
=
metrics
.
roc_curve
(
y
,
p
)
plt
.
plot
(
fpr
,
tpr
,
marker
=
'o'
)
plt
.
xlabel
(
'False positive rate'
)
plt
.
ylabel
(
'True positive rate'
)
plt
.
title
(
'roc_cureve'
)
#
plt.plot(fpr,tpr,marker = 'o')
#
plt.xlabel('False positive rate')
#
plt.ylabel('True positive rate')
# plt.title("roc_curev"
)
AUC
=
auc
(
fpr
,
tpr
)
AUC
=
"auc={}"
.
format
(
AUC
)
plt
.
text
(
0.5
,
0.8
,
AUC
,
color
=
'blue'
,
ha
=
'center'
)
plt
.
savefig
(
output
)
#
plt.text(0.5,0.8,AUC,color='blue',ha='center')
# #
plt.savefig(output)
print
(
AUC
)
except
:
print
(
"the format of the file must be the n*1"
)
...
...
@@ -41,4 +41,4 @@ def get_roc_curve(label,pred,output):
if
__name__
==
"__main__"
:
get_roc_curve
(
args
.
test_label
,
args
.
test_pred
,
args
.
output_photo
)
get_roc_curve
(
args
.
test_label
,
args
.
test_pred
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment