Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
emoUS-public
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
dsml
emoUS-public
Commits
77e39f4e
Commit
77e39f4e
authored
2 years ago
by
Hsien-Chin Lin
Browse files
Options
Downloads
Patches
Plain Diff
fix typo
parent
848c229a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
convlab/policy/emoUS/evaluate.py
+9
-8
9 additions, 8 deletions
convlab/policy/emoUS/evaluate.py
with
9 additions
and
8 deletions
convlab/policy/emoUS/evaluate.py
+
9
−
8
View file @
77e39f4e
...
...
@@ -9,6 +9,7 @@ import torch
from
datasets
import
load_metric
from
sklearn
import
metrics
from
tqdm
import
tqdm
from
pprint
import
pprint
from
convlab.nlg.evaluate
import
fine_SER
from
convlab.policy.emoUS.emoUS
import
UserActionPolicy
...
...
@@ -194,13 +195,13 @@ class Evaluator:
def
dialog_result
(
self
,
dialog
):
x
=
{
"
gen_acts
"
:
[],
"
golden_acts
"
:
[],
"
gen_emotion
s
"
:
[],
"
golden_emotion
s
"
:
[]}
"
gen_emotion
"
:
[],
"
golden_emotion
"
:
[]}
for
d
in
dialog
:
x
[
"
gen_acts
"
].
append
(
d
[
"
gen_acts
"
])
x
[
"
golden_acts
"
].
append
(
d
[
"
golden_acts
"
])
x
[
"
gen_emotion
s
"
].
append
(
d
[
"
gen_emotion
"
])
x
[
"
golden_emotion
s
"
].
append
(
d
[
"
golden_emotion
"
])
x
[
"
gen_emotion
"
].
append
(
d
[
"
gen_emotion
"
])
x
[
"
golden_emotion
"
].
append
(
d
[
"
golden_emotion
"
])
return
x
def
semantic_evaluation
(
self
,
x
):
...
...
@@ -246,8 +247,8 @@ class Evaluator:
self
.
evaluation_result
[
"
semantic action prediction
"
][
metric
]
=
score
if
not
golden_emotion
and
not
golden_action
:
r
=
emotion_score
(
x
[
"
golden_emotion
s
"
],
x
[
"
gen_emotion
s
"
],
r
=
emotion_score
(
x
[
"
golden_emotion
"
],
x
[
"
gen_emotion
"
],
self
.
model_checkpoint
)
self
.
evaluation_result
[
"
emotion prediction
"
][
"
emotion
"
]
=
{}
self
.
evaluation_result
[
"
emotion prediction
"
][
"
emotion
"
][
"
macro_f1
"
]
=
r
[
"
macro_f1
"
]
...
...
@@ -260,9 +261,9 @@ class Evaluator:
else
:
# transfer emotions to sentiment if the model do not generate sentiment
golden_sentiment
=
[
self
.
emo2sent
[
emo
]
for
emo
in
self
.
r
[
"
golden_emotion
s
"
]]
for
emo
in
self
.
r
[
"
golden_emotion
"
]]
gen_sentiment
=
[
self
.
emo2sent
[
emo
]
for
emo
in
self
.
r
[
"
gen_emotion
s
"
]]
for
emo
in
self
.
r
[
"
gen_emotion
"
]]
r
=
sentiment_score
(
golden_sentiment
,
gen_sentiment
,
...
...
@@ -273,7 +274,7 @@ class Evaluator:
self
.
evaluation_result
[
"
emotion prediction
"
][
"
sentiment
"
][
"
sep_f1
"
]
=
{
emo
:
f1
for
emo
,
f1
in
zip
(
r
[
"
label
"
],
r
[
"
sep_f1
"
])}
print
(
self
.
evaluation_result
)
p
print
(
self
.
evaluation_result
)
# def save_results(self):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment