FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
RECCON/eval_classification.py at main · declare-lab/RECCON · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
declare-lab
/
RECCON
Public
Notifications
You must be signed in to change notification settings
Fork
31
Star
191
Code
Issues
4
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
RECCON
/
eval_classification.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
65 lines (51 loc) · 2.5 KB
Breadcrumbs
RECCON
/
eval_classification.py
Copy path
File metadata and controls
65 lines (51 loc) · 2.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import
numpy
as
np
,
pandas
as
pd
import
json
,
os
,
logging
,
pickle
,
argparse
from
sklearn
.
metrics
import
classification_report
from
simpletransformers
.
classification
import
ClassificationModel
if
__name__
==
'__main__'
:
global
args
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'--batch-size'
,
type
=
int
,
default
=
8
,
metavar
=
'BS'
,
help
=
'batch size'
)
parser
.
add_argument
(
'--model'
,
default
=
'rob'
,
help
=
'which model rob| robl'
)
parser
.
add_argument
(
'--fold'
,
type
=
int
,
default
=
1
,
metavar
=
'F'
,
help
=
'which fold'
)
parser
.
add_argument
(
'--context'
,
action
=
'store_true'
,
default
=
False
,
help
=
'use context'
)
parser
.
add_argument
(
'--dataset'
,
default
=
'dailydialog'
,
help
=
'which dataset dailydialog | iemocap'
)
parser
.
add_argument
(
'--cuda'
,
type
=
int
,
default
=
0
,
metavar
=
'C'
,
help
=
'cuda device'
)
args
=
parser
.
parse_args
()
print
(
args
)
model_family
=
{
'rob'
:
'roberta'
,
'robl'
:
'roberta'
}
model_id
=
{
'rob'
:
'roberta-base'
,
'robl'
:
'roberta-large'
}
model_exact_id
=
{
'rob'
:
'roberta-base'
,
'robl'
:
'roberta-large'
}
batch_size
=
args
.
batch_size
model
=
args
.
model
fold
=
str
(
args
.
fold
)
context
=
args
.
context
dataset
=
args
.
dataset
cuda
=
args
.
cuda
if
context
==
False
:
max_seq_length
=
300
else
:
max_seq_length
=
512
if
context
==
False
:
save_dir
=
'outputs/'
+
model_id
[
model
]
+
'-dailydialog-cls-without-context-fold'
+
fold
+
'/'
x_test
=
pd
.
read_csv
(
'data/subtask2/fold'
+
fold
+
'/'
+
dataset
+
'_classification_test_without_context.csv'
)
else
:
save_dir
=
'outputs/'
+
model_id
[
model
]
+
'-dailydialog-cls-with-context-fold'
+
fold
+
'/'
x_test
=
pd
.
read_csv
(
'data/subtask2/fold'
+
fold
+
'/'
+
dataset
+
'_classification_test_with_context.csv'
)
test_args
=
{
'fp16'
:
False
,
'overwrite_output_dir'
:
False
,
'max_seq_length'
:
max_seq_length
,
'sliding_window'
:
False
,
'eval_batch_size'
:
batch_size
}
cls_model
=
ClassificationModel
(
model_family
[
model
],
save_dir
+
'best_model/'
,
args
=
test_args
,
cuda_device
=
cuda
)
result
,
model_outputs
,
wrong_predictions
=
cls_model
.
eval_model
(
x_test
)
preds
=
np
.
argmax
(
model_outputs
,
1
)
labels
=
x_test
[
'labels'
]
r
=
str
(
classification_report
(
labels
,
preds
,
digits
=
4
))
print
(
r
)
rf
=
open
(
'results/evaluation_'
+
dataset
+
'_classification.txt'
,
'a'
)
rf
.
write
(
str
(
args
)
+
'
\n
\n
'
)
rf
.
write
(
r
+
'
\n
'
+
'-'
*
54
+
'
\n
'
)
rf
.
close
()
Back
|
FazBrowse Home
|
New Git URL