Commit 0850d7be by Pamela Osuna

multilabel version

parent c095d72c
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment