【发布时间】:2017-02-08 18:48:25
【问题描述】:
我是 Python 新手,我正在使用以下方式以链接列表矩阵格式存储数据。
>>> from scipy import sparse,random
>>> m = 2
>>> X = [sparse.lil_matrix((5,5)) for i in range(m)]
>>> X[0][0,1] = 1
>>> X[0][2,3] = 1
>>> X[1][0,4] = 1
>>> X[1][1,4] = 1
>>> X[1][2,4] = 1
>>> X
[<5x5 sparse matrix of type '<type 'numpy.float64'>'
with 2 stored elements in LInked List format>, <5x5 sparse matrix of type '<type 'numpy.float64'>'
with 3 stored elements in LInked List format>]
有没有办法将这个 lil_matrix X 随机划分为训练(75%)和测试集(25%)
【问题讨论】: