Scipy 矩阵 - Sklearn 的描述
我正在使用 sklearn 进行 NPL,将我的数据集放入训练和测试集中,如下所示:
X_train, X_test, y_train, y_test = train_test_split(X,Y,test_size=0.3, shuffle=True,random_state=0,stratify=Y)
如何获得 X_train 和 y_train 的描述(即每个标签有多少个寄存器),因为生成的对象是类'scipy.sparse.csr.csr_matrix' 并且没有描述属性。
I'm working on NPL with sklearn, slipt my data set into training and test sets as follow:
X_train, X_test, y_train, y_test = train_test_split(X,Y,test_size=0.3, shuffle=True,random_state=0,stratify=Y)
How I can get a description of the X_train and y_train (i.e. how many registers has of each label), due that the resulting objects are class 'scipy.sparse.csr.csr_matrix' and does not have a description attribute.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
csr_matrix
是一个稀疏矩阵由scipy
提供。如果您想检查其内容,可以调用.toarray()
,返回该矩阵的密集 ndarray 表示。例如,
print(X_train.toarray())
csr_matrix
is a sparse matrix provided byscipy
. If you want to inspect its content, you could call.toarray()
on it, which return a dense ndarray representation of this matrix.For example,
print(X_train.toarray())