python关于矩阵重复赋值覆盖问题的解决方法-创新互联

本文实例讲述了python关于矩阵重复赋值覆盖问题的解决方法。分享给大家供大家参考,具体如下:

创新互联主营团风网站建设的网络公司,主营网站建设方案,APP应用开发,团风h5小程序开发搭建,团风网站营销推广欢迎团风等地区企业咨询
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]))


文章标题:python关于矩阵重复赋值覆盖问题的解决方法-创新互联
网站路径:http://ybzwz.com/article/phjoe.html