Keras预测收集在一堂课

时间:2018-10-13 14:09:51

标签: python machine-learning keras

©我正在使用keras和python 2.x并试图对数据集进行分类。问题是预测总是聚集在一堂课中。

我是keras的新手,我该怎么办?

这是我的困惑母女;

    Confusion Matrix
    [[  0  37   0]
     [  0 823   0]
     [  0  26   0]]

这是我的报告。

 precision    recall  f1-score   support

     -1       0.00      0.00      0.00        37
      0       0.93      1.00      0.96       823
      1       0.00      0.00      0.00        26

平均/总计0.86 0.93 0.89 886

这是我的代码:

dataset= pd.read_csv("kartnEgitim.csv"  )

giris=dataset.iloc [40:,1:20].get_values()
cikis=dataset.iloc [40:,20].get_values()

from sklearn.model_selection import train_test_split
egitimData, testData, egitimEtiket, testEtiket = train_test_split(giris, cikis, test_size = 0.2)

#from sklearn.preprocessing import StandardScaler
#sc = StandardScaler()
#egitimData = sc.fit_transform(egitimData)
#testData = sc.transform(testData)

egitimData=keras.utils.normalize(egitimData,axis=1)
testData=keras.utils.normalize(testData,axis=1)

model=Sequential()
model.add(Dense(6,input_dim=19,activation='relu'))
model.add(Dropout(0.5))

model.add(Dense(6,activation='relu'))
model.add(Dropout(0.5))

model.add(Dense(3))
model.add(Activation('softmax'))


model.compile(optimizer='adam' ,loss='sparse_categorical_crossentropy' , metrics=['accuracy'])
model.fit(egitimData, egitimEtiket,epochs=10,batch_size=64,class_weight='auto') # ,batch_size=64

val_loss, val_acc=model.evaluate(testData,testEtiket)
print(val_loss,val_acc)

# Predicting the Test set results
predictions = model.predict_classes(testData)

from sklearn.metrics import confusion_matrix,classification_report
print('Confusion Matrix')
cm = confusion_matrix(testEtiket, predictions, labels=[-1, 0, 1])
print (cm)

print('Classification Report')
print(classification_report(testEtiket, predictions,target_names = ['-1', '0', '1']))

我是keras的新手,我该怎么办?

0 个答案:

没有答案