解决only integer scalar arrays can be converted to a scalar index

简介: 解决only integer scalar arrays can be converted to a scalar index

Traceback (most recent call last):
  File "E:/Code/PyCharm/SaltedFish/咸鱼12/K_Fold.py", line 71, in <module>
    x_ = x_train[train]
TypeError: only integer scalar arrays can be converted to a scalar index

问题原因:

制作训练数据我使用的是二维列表,这就会导致在进行样本切片出现问题

解决办法:

使用numpy将二维列表转化成array类型

data = np.array(data_set)


目录
相关文章
|
3月前
|
Python
string indices must be integers
string indices must be integers
41 0
|
5月前
|
数据处理 开发者 Python
【Python】已解决:ValueError: Length mismatch: Expected axis has 5 elements, new values have 4 elements
【Python】已解决:ValueError: Length mismatch: Expected axis has 5 elements, new values have 4 elements
363 9
|
7月前
|
Python
完美解决丨2. `TypeError: list indices must be integers or slices, not str`
完美解决丨2. `TypeError: list indices must be integers or slices, not str`
LeetCode 307. Range Sum Query - Mutable
update(i, val) 函数可以通过将下标为 i 的数值更新为 val,从而对数列进行修改。
106 0
LeetCode 307. Range Sum Query - Mutable
|
索引
LeetCode 303. Range Sum Query - Immutable
给定一个整数数组 nums,求出数组从索引 i 到 j (i ≤ j) 范围内元素的总和,包含 i, j 两点。
97 0
LeetCode 303. Range Sum Query - Immutable
LeetCode 304. Range Sum Query 2D - Immutable
给定一个二维矩阵,计算其子矩形范围内元素的总和,该子矩阵的左上角为 (row1, col1) ,右下角为 (row2, col2)。
106 0
LeetCode 304. Range Sum Query 2D - Immutable
TypeError: cannot concatenate ‘str‘ and ‘list‘ objects
TypeError: cannot concatenate ‘str‘ and ‘list‘ objects
|
索引 Python
成功解决ValueError: column index (256) not an int in range(256)
成功解决ValueError: column index (256) not an int in range(256)
成功解决ValueError: column index (256) not an int in range(256)
|
存储 索引
成功解决ValueError: If using all scalar values, you must pass an index
成功解决ValueError: If using all scalar values, you must pass an index
|
数据库
Data truncation: Out of range value for column ‘estimate_score‘
Data truncation: Out of range value for column ‘estimate_score‘