def output_groups(tcs, alpha, mis, column_label, thresh=0, prefix=''):
f = safe_open(prefix + '/text_files/groups.txt', 'w+')
g = safe_open(prefix + '/text_files/groups_no_overlaps.txt', 'w+')
m, nv = mis.shape
for j in range(m):
f.write('Group num: %d, TC(X;Y_j): %0.3f\n' % (j, tcs[j]))
g.write('Group num: %d, TC(X;Y_j): %0.3f\n' % (j, tcs[j]))
inds = np.where(alpha[j] * mis[j] > thresh)[0]
inds = inds[np.argsort(-alpha[j, inds] * mis[j, inds])]
for ind in inds:
f.write(column_label[ind] + ', %0.3f, %0.3f, %0.3f\n' % (
mis[j, ind], alpha[j, ind], mis[j, ind] * alpha[j, ind]))
inds = np.where(alpha[j] == 1)[0]
inds = inds[np.argsort(- mis[j, inds])]
for ind in inds:
g.write(column_label[ind] + ', %0.3f\n' % mis[j, ind])
f.close()
g.close()
评论列表
文章目录