分类ANN卡在60%

我在一个包含10,000条数据的数据集上尝试创建一个二元分类器。我尝试了多种激活函数和优化器,但结果始终在56.8%到58.9%之间。鉴于在数十次迭代中结果相当稳定,我假设问题出在以下两点之一:

  1. 我的数据集不可分类
  2. 我的模型有问题

这是数据集:training-set.csv

我可能会再获得2000条记录,但仅此而已。

我的问题是: 我的模型构建方式是否存在某些问题,导致无法更高程度地学习?

请注意,我愿意使用尽可能多的层和节点,生成模型的时间不是问题。

dataframe = pandas.read_csv(r"training-set.csv", index_col=None)dataset = dataframe.valuesX = dataset[:,0:48].astype(float)Y = dataset[:,48]#count the input variablescol_count = X.shape[1]#normalize Xfrom sklearn.preprocessing import StandardScalersc_X = StandardScaler()X_scale = sc_X.fit_transform(X)# Splitting the dataset into the Training set and Test setfrom sklearn.model_selection import train_test_splitX_train, X_test, y_train, y_test = train_test_split(X_scale, Y, test_size = 0.2)# define baseline modelactivator = 'linear' #'relu' 'sigmoid' 'softmax' 'exponential' 'linear' 'tanh'#opt = 'Adadelta' #adam SGD nadam RMSprop Adadelta nodes = 1000 max_layers = 2max_epochs = 100max_batch = 32loss_funct = 'binary_crossentropy' #for binarylast_act = 'sigmoid' # 'softmax' 'sigmoid' 'relu'def baseline_model():    # create model    model = Sequential()    model.add(Dense(nodes, input_dim=col_count, activation=activator))    for x in range(0, max_layers):        model.add(Dropout(0.2))        model.add(Dense(nodes, input_dim=nodes, activation=activator))        #model.add(BatchNormalization())    model.add(Dense(1, activation=last_act)) #model.add(Dense(1, activation=last_act))     # Compile model    adam = Adam(lr=0.001)    model.compile(loss=loss_funct, optimizer=adam, metrics=['accuracy'])    return modelestimator = KerasClassifier(build_fn=baseline_model, epochs=max_epochs, batch_size=max_batch)estimator.fit(X_train, y_train)y_pred = estimator.predict(X_test)#confusion matrixfrom sklearn.metrics import confusion_matrixcm = confusion_matrix(y_test, y_pred)score = np.sum(cm.diagonal())/float(np.sum(cm))

回答:

两点建议:

  1. 绝对没有必要使用线性激活函数堆叠密集层——它们只会变成一个线性单元;改为 activator = 'relu'(并且不必考虑你注释掉的列表中的其他候选激活函数)。

  2. 不要默认使用dropout,特别是当你的模型在学习上有困难时(如这里的情况);移除dropout层,只需准备在看到过拟合时再放回(你目前离过拟合还很远,所以现在不必担心这一点)。

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注