过滤行列

 1 import numpy as np
 2 
 3 features = np.array([[1,2,3],[4,5,6],[7,8,9]])
 4 components = [True,True,True]
 5 features = features[:, components]
 6 print(features)
 7 fea = np.array([[1,2,3],[4,5,6],[7,8,9]])
 8 components = [True,False,True]
 9 fea = fea[:, components]
10 print(fea)

结果:

[[1 2 3]
[4 5 6]
[7 8 9]]


[[1 3]
[4 6]
[7 9]]

猜你喜欢

转载自www.cnblogs.com/shuangcao/p/12908887.html