Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
senpy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
6
Issues
6
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
1
Merge Requests
1
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
senpy
senpy
Commits
d6f4cc2d
Commit
d6f4cc2d
authored
Jan 22, 2018
by
Ignacio Corcuera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Connecting the Plugin to the evaluation module of GSITK
parent
4af69209
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
+45
-0
senpy/plugins/__init__.py
senpy/plugins/__init__.py
+45
-0
No files found.
senpy/plugins/__init__.py
View file @
d6f4cc2d
...
...
@@ -22,6 +22,9 @@ import threading
from
..
import
models
,
utils
from
..
import
api
from
gsitk.evaluation.evaluation
import
Evaluation
as
Eval
from
sklearn.pipeline
import
Pipeline
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -320,6 +323,48 @@ class EmotionBox(TextBox, EmotionPlugin):
return
entry
class
EvaluationBox
():
'''
A box plugin where it is implemented the evaluation. It is necessary to have a pipeline.
'''
def
score
(
self
,
datasets
):
pipelines
=
[
self
.
_pipeline
]
ev
=
Eval
(
tuples
=
None
,
datasets
=
datasets
,
pipelines
=
pipelines
)
ev
.
evaluate
()
results
=
ev
.
results
evaluations
=
self
.
_evaluations_toJSONLD
(
results
)
return
evaluations
def
_evaluations_toJSONLD
(
self
,
results
):
'''
Map the evaluation results to a JSONLD scheme
'''
evaluations
=
list
()
metric_names
=
[
'accuracy'
,
'precision_macro'
,
'recall_macro'
,
'f1_macro'
,
'f1_weighted'
,
'f1_micro'
,
'f1_macro'
]
for
index
,
row
in
results
.
iterrows
():
evaluation
=
models
.
Evaluation
()
if
row
[
'CV'
]
==
False
:
evaluation
[
'@type'
]
=
[
'StaticCV'
,
'Evaluation'
]
evaluation
.
evaluatesOn
=
row
[
'Dataset'
]
evaluation
.
evaluates
=
row
[
'Model'
]
i
=
0
for
name
in
metric_names
:
metric
=
models
.
Metric
()
metric
[
'@id'
]
=
'Metric'
+
str
(
i
)
metric
[
'@type'
]
=
name
.
capitalize
()
metric
.
value
=
row
[
name
]
evaluation
.
metrics
.
append
(
metric
)
i
+=
1
evaluations
.
append
(
evaluation
)
return
evaluations
class
MappingMixin
(
object
):
@
property
...
...
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