5-21日

1.as.vector(x) : 没有可用来把这个S4类别强迫改为矢量的方法

 这个的话我们通过typeof /mode,命令可以知道对象是s4类型的,直接用@访问即可,它内部还会有别的对象,

2. 一个矩阵/一个列表

https://www.csdn.net/gather_23/MtjaIg4sNjMwLWJsb2cO0O0O.html,这个讲的还不错。

import numpy as np
a=np.array( [[2, 2, 5, 2], [3, 3, 5, 1], [4, 4, 5, 2]])
print(a)
print(a/np.sum(a,axis=1,keepdims=True))


[[2 2 5 2]
 [3 3 5 1]
 [4 4 5 2]]
[[0.18181818 0.18181818 0.45454545 0.18181818]
 [0.25       0.25       0.41666667 0.08333333]
 [0.26666667 0.26666667 0.33333333 0.13333333]]

猜你喜欢

转载自www.cnblogs.com/BlueBlueSea/p/12935340.html