Where does a value go when samples and features trade axes?

transpose permutes axes. Transposing a table moves the value at row i, column j to row j, column i.

numpy.transpose in practice

Two subjects each have three measurements. After transposition each row follows one measurement across both subjects. A one-dimensional vector has no second axis to exchange.

import numpy as np
np.transpose([[1,2,3],[4,5,6]])

Result [[1, 4], [2, 5], [3, 6]]

中文

交换样本轴和特征轴后,值去了哪里?

transpose 重排轴。二维表的行列互换后,第 i 行第 j 列的值出现在第 j 行第 i 列。

numpy.transpose 算例

两名观测对象各有三项测量。转置后的每一行是一项测量在两人身上的取值。对一维向量转置不会凭空增加列轴。

import numpy as np
np.transpose([[1,2,3],[4,5,6]])

结果 [[1, 4], [2, 5], [3, 6]]

References / 参考来源

Keep reading / 继续阅读