在 CNN 中使用通用 类 对数组进行分类以进行分类

Grouping arrays with common classes for classification in CNN

我有一个三列的数据集,前两列是特征,第三列包含classes,有4个classes,部分可以在这里看到.

数据集很大,假设有 100,000 行和 3 列(两列特征和一列用于 classes),所以我在上使用长度为 50 的移动 window训练我的深度学习模型之前的数据集。到目前为止,我已经尝试了两种不同的方法来对数据集进行切片,但效果不佳,而且我很确定我的数据集是好的。 我首先在我的整个数据集上使用了一个移动 window,产生了 2000 个数据样本,有 50 行和 2 列 (2000,50,2)。由于一些数据样本包含混合 classes,我只选择了具有共同 classes 的数据样本,并找到 classes 的平均值以将该特定数据样本分配到单个 [=28] =] 只是,我没有得到 this.Here 的结果是我的代码,`

def moving_window(data_, length, step=1):
    streams = it.tee(data_, length)
    return zip(*[it.islice(stream, i, None, step * length) for stream, i in zip(streams, it.count(step=step))])


data = list(moving_window(data_, 50))
data = np.asarray(data)
# print(len(data))
for i in data:
    label=np.all(i==i[0,2],axis=0)

    if label[2]==True:
        X.append(i[:,0:2])
        Y.append(sum(i[:,2])/len(i[:,2]))`

我尝试了另一种方法,只收集与特定 class 相对应的特征,将值放入单独的列表(4 个列表,因为我有 4 个 classes)然后使用移动 window 分别对每个列表进行切片并分配给它的 class。没有好的结果too.Here是我的代码

for i in range(5):
    labels.append(i)
yy= pd.get_dummies(labels)
yy= yy.values
yy= yy.astype(np.float32)


def moving_window(x, length, step=1):
    streams = it.tee(x, length)
    return zip(*[it.islice(stream, i, None, step * length) for stream, i in zip(streams, it.count(step=step))])


x_1 = list(moving_window(x1, 50))
x_1 = np.asarray(x_1)
y_1 = [yy[0]] * len(x_1)
X.append(x_1)
Y.append(y_1)
# print(x_1.shape)

x_2 = list(moving_window(x2, 50))
x_2 = np.asarray(x_2)
# print(yy[1])
y_2 = [yy[1]] * len(x_2)
X.append(x_2)
Y.append(y_2)
# print(x_2.shape)

x_3 = list(moving_window(x3, 50))
x_3 = np.asarray(x_3)
# print(yy[2])
y_3 = [yy[2]] * len(x_3)
X.append(x_3)
Y.append(y_3)
# print(x_3.shape)

x_4 = list(moving_window(x4, 50))
x_4 = np.asarray(x_4)
# print(yy[3])
y_4 = [yy[3]] * len(x_4)
X.append(x_4)
Y.append(y_4)
# print(x_4.shape)

我尝试训练的模型架构与其他数据集完美配合。所以我想我在如何处理 data.What 上遗漏了一些东西,我在开始训练之前是否遗漏了处理数据的方法?还有其他方法吗?。所有完成的工作都在 python.

我终于成功地训练了我的 CNN 模型,并取得了良好的训练、验证和测试准确性。我唯一添加的是使用以下行对我的输入数据进行规范化,

minmax_scale = preprocessing.MinMaxScaler().fit(x)
X = minmax_scale.transform(x)

其余不变