x_train:(153347,53)x_test:(29039,52)y:(153347,)
我正在使用sklearn。为了进行交叉验证和重塑我的数据集,我做了以下操作:
x_train, x_test, y_train, y_test = cross_validation.train_test_split(x, y, test_size=0.3)x_train = np.pad(x, [(0,0)], mode='constant')x_test = np.pad(x, [(0,0)], mode='constant')y = np.pad(y, [(0,0)], mode='constant')x_train = np.arange(8127391).reshape((-1,1))c = x.Tnp.all(x_train == c)x_test = np.arange(1510028).reshape((-1,1))c2 = x.Tnp.all(x_test == c2)y = np.arange(153347).reshape((-1,1))c3 = x.Tnp.all(y == c3)
我的错误信息是:ValueError: 发现样本数量不一致的数组:[ 2 153347]
我不确定在这种情况下是否需要填充我的数据集,而且重塑操作未能成功。有什么方法可以解决这个问题吗?
回答:
从我们看到的少量信息来看,我认为调用cross_validation.train_test_split
失败是因为两个向量的长度不一致。因此,对于每一个X(你观察到的数据元组),你需要一个Y(作为结果观察到的数据点)。
至少这导致了上述错误的出现。
你应该在问题描述上做得更好,非常重要。
此致,fricke