mat函数可以将目标数据的类型转换为矩阵(matrix)
data=[[1,1,0,3,1],[1,0,1,4,3],[1,0,1,2,4],[0,1,1,1,2], [2,0,0,3,0],[1,0,1,3,1],[0,1,1,0,2],[0,1,1,0,3], [2,0,0,5,1],[2,0,0,2,0],[0,0,2,1,3],[0,0,2,0,4], [2,0,0,7,0],[2,0,0,6,2],[0,0,2,2,5],[0,0,2,0,8], [2,0,0,6,0],[2,0,0,8,0],[0,0,2,0,10],[0,0,2,0,4], [1,0,0,3,2],[1,0,0,2,1],[0,0,1,2,3],[0,0,1,1,2]] datamat=np.mat(data) print(datamat) print() print(data)
输出结果,一个是矩阵,一个是列表