Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
outillage
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package 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
Alice Brenon
outillage
Commits
0d657426
Commit
0d657426
authored
1 year ago
by
Alice Brenon
Browse files
Options
Downloads
Patches
Plain Diff
Fix mistakes created when refactoring
parent
75f61841
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
scripts/ML/BERT/Base.py
+4
-4
4 additions, 4 deletions
scripts/ML/BERT/Base.py
scripts/ML/BERT/Trainer.py
+4
-0
4 additions, 0 deletions
scripts/ML/BERT/Trainer.py
scripts/ML/Corpus.py
+7
-5
7 additions, 5 deletions
scripts/ML/Corpus.py
scripts/ML/predict.py
+2
-2
2 additions, 2 deletions
scripts/ML/predict.py
with
17 additions
and
11 deletions
scripts/ML/BERT/Base.py
+
4
−
4
View file @
0d657426
...
@@ -42,15 +42,15 @@ class BERT:
...
@@ -42,15 +42,15 @@ class BERT:
print
(
'
Loading BERT tools
'
)
print
(
'
Loading BERT tools
'
)
self
.
_init_tokenizer
()
self
.
_init_tokenizer
()
self
.
root_path
=
root_path
self
.
root_path
=
root_path
_init_classifier
(
training
)
self
.
_init_classifier
(
training
)
@loader
@loader
def
_init_tokenizer
():
def
_init_tokenizer
(
self
):
self
.
tokenizer
=
BertTokenizer
.
from_pretrained
(
BERT
.
model_name
)
self
.
tokenizer
=
BertTokenizer
.
from_pretrained
(
BERT
.
model_name
)
@loader
@loader
def
_init_classifier
(
training
)
def
_init_classifier
(
self
,
training
)
:
if
training
if
training
:
bert
=
BertForSequenceClassification
.
from_pretrained
(
bert
=
BertForSequenceClassification
.
from_pretrained
(
model_name
,
# Use the 12-layer BERT model, with an uncased vocab.
model_name
,
# Use the 12-layer BERT model, with an uncased vocab.
num_labels
=
numberOfClasses
,
# The number of output labels--2 for binary classification.
num_labels
=
numberOfClasses
,
# The number of output labels--2 for binary classification.
...
...
This diff is collapsed.
Click to expand it.
scripts/ML/BERT/Trainer.py
+
4
−
0
View file @
0d657426
from
BERT.Base
import
BERT
class
Trainer
(
BERT
):
pass
This diff is collapsed.
Click to expand it.
scripts/ML/Corpus.py
+
7
−
5
View file @
0d657426
...
@@ -30,6 +30,8 @@ class TSVIndexed(Corpus):
...
@@ -30,6 +30,8 @@ class TSVIndexed(Corpus):
self
.
tsv_path
=
tsv_path
self
.
tsv_path
=
tsv_path
self
.
column_name
=
column_name
self
.
column_name
=
column_name
self
.
data
=
None
self
.
data
=
None
self
.
projectors
=
dict
((
p
,
self
.
__getattribute__
(
p
))
for
p
in
[
'
key
'
,
'
content
'
,
'
full
'
])
def
load
(
self
):
def
load
(
self
):
if
self
.
data
is
None
:
if
self
.
data
is
None
:
...
@@ -46,19 +48,19 @@ class TSVIndexed(Corpus):
...
@@ -46,19 +48,19 @@ class TSVIndexed(Corpus):
def
content
(
self
,
key
,
row
):
def
content
(
self
,
key
,
row
):
pass
pass
def
key
s
(
self
,
_
,
row
):
def
key
(
self
,
_
,
row
):
return
row
[
self
.
keys
].
to_dict
()
return
row
[
self
.
keys
].
to_dict
()
def
full
(
self
,
key
,
row
):
def
full
(
self
,
key
,
row
):
d
=
self
.
key
s
(
key
,
row
)
d
=
self
.
key
(
key
,
row
)
d
[
self
.
column_name
]
=
self
.
content
(
key
,
row
).
strip
()
+
'
\n
'
d
[
self
.
column_name
]
=
self
.
content
(
key
,
row
).
strip
()
+
'
\n
'
return
d
return
d
def
get_all
(
self
,
projector
):
def
get_all
(
self
,
projector
=
None
):
if
projector
is
None
:
if
projector
is
None
:
projector
=
self
.
full
projector
=
self
.
full
elif
type
(
projector
)
==
str
:
elif
type
(
projector
)
==
str
and
projector
in
self
.
projectors
:
projector
=
self
.
__getattribute__
(
projector
)
projector
=
self
.
projectors
[
projector
]
self
.
load
()
self
.
load
()
for
row
in
self
.
data
.
iterrows
():
for
row
in
self
.
data
.
iterrows
():
yield
projector
(
*
row
)
yield
projector
(
*
row
)
...
...
This diff is collapsed.
Click to expand it.
scripts/ML/predict.py
+
2
−
2
View file @
0d657426
...
@@ -21,8 +21,8 @@ def label(classify, source, name='label'):
...
@@ -21,8 +21,8 @@ def label(classify, source, name='label'):
:return: a panda dataframe containing the records from the input TSV file plus
:return: a panda dataframe containing the records from the input TSV file plus
an additional column
an additional column
"""
"""
records
=
pandas
.
DataFrame
(
source
.
get_all
(
'
key
s
'
))
records
=
pandas
.
DataFrame
(
source
.
get_all
(
'
key
'
))
records
[
name
]
=
classify
(
source
.
get_all
(
'
content
'
)
records
[
name
]
=
classify
(
source
.
get_all
(
'
content
'
)
)
return
records
return
records
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
...
...
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