Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
antifragility
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ana Pamela Osuna Vargas
antifragility
Commits
0850d7be
Commit
0850d7be
authored
Jan 24, 2020
by
Pamela Osuna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
multilabel version
parent
c095d72c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
0 deletions
+39
-0
output_convert2.py
+39
-0
No files found.
output_convert2.py
0 → 100644
View file @
0850d7be
from
itertools
import
product
B
=
[
0
,
1
]
converter
=
{(
e
,
r
):[
i
]
for
(
e
,
r
),
i
in
zip
(
product
(
B
,
B
),
range
(
4
))}
reverse
=
{(
i
):[
e
,
r
]
for
(
e
,
r
),
i
in
zip
(
product
(
B
,
B
),
range
(
4
))}
def
output_convert
(
e
,
r
):
"""
Encodes outputs as integers
Parameters
-----------
e : 1 evolvable, 0 not evolvable
r : 1 robust, 0 not robust
Returns
-----------
the encoded output
output meaning:
0 : not evolv. and not rob.
1 : evol. and not rob.
2 : not evol. and rob.
3 : evol. and rob.
"""
return
converter
[
e
,
r
]
def
binary_convert
(
y_bin
):
"""
From binary to normal
"""
y_final
=
np
.
array
([
converter
[
y_bin
[
i
,
0
],
y_bin
[
i
,
1
]]
for
i
in
range
(
len
(
y_bin
))])
return
y_final
def
output_reverse
(
y
):
"""
From normal to binary
"""
y_bin
=
np
.
array
([
reverse
[
y
[
i
]]
for
i
in
range
(
len
(
y
))])
return
y_bin
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