本文實例講述了python關(guān)于矩陣重復賦值覆蓋問題的解決方法。分享給大家供大家參考,具體如下:
創(chuàng)新互聯(lián)主營團風網(wǎng)站建設(shè)的網(wǎng)絡公司,主營網(wǎng)站建設(shè)方案,APP應用開發(fā),團風h5小程序開發(fā)搭建,團風網(wǎng)站營銷推廣歡迎團風等地區(qū)企業(yè)咨詢import itertools import numpy as np comb = list(itertools.combinations(list(range(regions)), 2)) bands_info = [] coeff = np.zeros([bands, len(comb)]) for cla in range(classes): class_info = data[:,cla*bands*regions:(cla+1)*bands*regions] for bs in range(bands): n = bs*regions for i in range(len(comb)): index1 = comb[i][0]+n index2 = comb[i][1]+n part1 = class_info[:, index1] part2 = class_info[:, index2] coeff[bs, i] = (np.corrcoef(part1, part2))[0, 1] bands_info.append(coeff.reshape([1,-1])) coeff_info = np.vstack((bands_info[0], bands_info[1], bands_info[2],bands_info[3]))