X_train = np.array([row[:-1] for row in trainingSet]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was
时间: 2023-07-24 20:40:20 浏览: 100
This error occurs when you are trying to assign a sequence of values to an array element that expects a single value. The error message is telling you that the shape of the array is not homogeneous, meaning that the elements in the array do not have the same shape.
In this case, it seems like you are trying to create a NumPy array from a list of sequences, but the sequences do not have the same length. This can happen if the rows in your trainingSet have different lengths.
To fix this error, you need to make sure that all the rows in your trainingSet have the same length. You can do this by padding the shorter rows with zeros or by truncating the longer rows to the same length as the shortest row.
Once all the rows have the same length, you can create the NumPy array using the following code:
```
X_train = np.array(trainingSet)
```
This will create an array where each row corresponds to a row in the trainingSet list.
阅读全文