Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
ppg-moderation-classifier
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
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
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
oschmanf
ppg-moderation-classifier
Commits
7d0a677a
Commit
7d0a677a
authored
1 year ago
by
Franziska Oschmann
Browse files
Options
Downloads
Patches
Plain Diff
Adjust averaging of precision, recall, f1
parent
9fcfed88
No related branches found
Branches containing commit
No related tags found
1 merge request
!2
Dev train models
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
moderation_classifier/eval_BERT.py
+5
-5
5 additions, 5 deletions
moderation_classifier/eval_BERT.py
moderation_classifier/eval_MNB.py
+3
-2
3 additions, 2 deletions
moderation_classifier/eval_MNB.py
with
8 additions
and
7 deletions
moderation_classifier/eval_BERT.py
+
5
−
5
View file @
7d0a677a
...
...
@@ -49,16 +49,16 @@ def main(train_logs: Union[str, os.PathLike]):
text_proc
=
tp
.
fit_transform
(
df_de
.
text
)
df_de
.
text
=
text_proc
comon_topics
=
tl
.
get_comments_per_topic
(
df_de
)
# Load tokenizer and model
tokenizer
=
AutoTokenizer
.
from_pretrained
(
"
bert-base-german-cased
"
)
model
=
TFAutoModelForSequenceClassification
.
from_pretrained
(
pretrained_model_name_or_path
=
path_model
)
# Split text into batches
text_list
=
list
(
df_de
.
text
.
values
)
n
=
5
00
n
=
1
00
results
=
[
text_list
[
idx
:
idx
+
n
]
for
idx
in
range
(
0
,
len
(
text_list
),
n
)]
import
pdb
;
pdb
.
set_trace
()
# eval all
y_pred_all
=
[]
for
batch
in
tqdm
(
results
):
...
...
@@ -70,7 +70,7 @@ def main(train_logs: Union[str, os.PathLike]):
y_pred_all
=
np
.
concatenate
(
y_pred_all
)
precision
,
recall
,
f1
,
_
=
precision_recall_fscore_support
(
df_de
.
label
,
y_pred_all
,
average
=
"
weighted
"
df_de
.
label
,
y_pred_all
,
average
=
'
weighted
'
)
accuracy
=
accuracy_score
(
df_de
.
label
,
y_pred_all
)
...
...
@@ -89,7 +89,7 @@ def main(train_logs: Union[str, os.PathLike]):
y_pred_t
=
y_pred_all
[
df_de
.
topic
==
t
]
precision
,
recall
,
f1
,
_
=
precision_recall_fscore_support
(
y_test_t
,
y_pred_t
,
average
=
"
weighted
"
y_test_t
,
y_pred_t
,
average
=
'
weighted
'
)
accuracy
=
accuracy_score
(
y_test_t
,
y_pred_t
)
results_t
[
t
]
=
dict
()
...
...
This diff is collapsed.
Click to expand it.
moderation_classifier/eval_MNB.py
+
3
−
2
View file @
7d0a677a
...
...
@@ -45,6 +45,7 @@ def main(train_logs: Union[str, os.PathLike]):
remove_duplicates
=
False
,
min_num_words
=
3
,
)
X_test
=
df_test
.
text
y_test
=
df_test
.
label
...
...
@@ -53,7 +54,7 @@ def main(train_logs: Union[str, os.PathLike]):
y_pred_t
=
pipe
.
predict
(
X_test
)
precision
,
recall
,
f1
,
_
=
precision_recall_fscore_support
(
y_test
,
y_pred
,
average
=
"
weighted
"
y_test
,
y_pred
,
average
=
'
weighted
'
)
accuracy
=
pipe
.
score
(
X_test
,
y_test
)
...
...
@@ -76,7 +77,7 @@ def main(train_logs: Union[str, os.PathLike]):
y_pred_t
=
pipe
.
predict
(
X_test_t
)
precision
,
recall
,
f1
,
_
=
precision_recall_fscore_support
(
y_test_t
,
y_pred_t
,
average
=
"
weighted
"
y_test_t
,
y_pred_t
,
average
=
'
weighted
'
)
#f1 = f1_score(y_test_t, y_pred_t)
accuracy
=
pipe
.
score
(
X_test_t
,
y_test_t
)
...
...
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