def get_L_yXL(fname, y, x_in_X, L):
def _get_L_yXL_per_yXL(fname, x_in_X, X_index,<EOL>y, layer):<EOL><INDENT>f = open(fname, '<STR_LIT:r>')<EOL>data = json.load(f)<EOL>f.close()<EOL>if layer in [str(key) for key in list(data['<STR_LIT:data>'][y]['<STR_LIT>'].keys())]:<EOL><INDENT>k_yXL = <NUM_LIT:0><EOL>k_yX = <NUM_LIT:0><EOL>for x in x_in_X[X_index]:<EOL><INDENT>p_yxL = data['<STR_LIT:data>'][y]['<STR_LIT>'][layer][x] / <NUM_LIT><EOL>k_yL = data['<STR_LIT:data>'][y]['<STR_LIT>'][layer]['<STR_LIT>']<EOL>k_yXL += p_yxL * k_yL<EOL><DEDENT>for l in [str(key) for key in list(data['<STR_LIT:data>'][y]['<STR_LIT>'].keys())]:<EOL><INDENT>for x in x_in_X[X_index]:<EOL><INDENT>p_yxL = data['<STR_LIT:data>'][y]['<STR_LIT>'][l][x] / <NUM_LIT><EOL>k_yL = data['<STR_LIT:data>'][y]['<STR_LIT>'][l]['<STR_LIT>']<EOL>k_yX +=  p_yxL * k_yL<EOL><DEDENT><DEDENT>if k_yXL != <NUM_LIT:0.>:<EOL><INDENT>return k_yXL / k_yX<EOL><DEDENT>else:<EOL><INDENT>return <NUM_LIT:0.><EOL><DEDENT><DEDENT>else:<EOL><INDENT>return <NUM_LIT:0.><EOL><DEDENT><DEDENT>L_yXL = {}<EOL>for y_value in y:<EOL><INDENT>data = np.zeros((len(L), len(x_in_X)))<EOL>for i, Li in enumerate(L):<EOL><INDENT>for j in range(len(x_in_X)):<EOL><INDENT>data[i][j]= _get_L_yXL_per_yXL(fname, x_in_X,<EOL>X_index=j,<EOL>y=y_value,<EOL>layer=Li)<EOL><DEDENT><DEDENT>L_yXL[y_value] = data<EOL><DEDENT>return L_yXL<EOL>
compute the layer specificity, defined as:
::

    L_yXL = k_yXL / k_yX