Exemple #1
0
 def evaluate_accurancy(self, filename=''):
     """
     Evaluate the Result of the emotion analyze
     """
     from pycm import ConfusionMatrix
     #actual_vector = self._data[CorporaProperties.EMOTION.value]
     actual_vector = self._data.loc[:,
                                    CorporaProperties.EMOTION.value].values
     #print(actual_vector)
     #predict_vector = self._data[CorporaProperties.CALCULATED_EMOTION.value]
     predict_vector = self._data.loc[:, CorporaProperties.
                                     CALCULATED_EMOTION.value].values
     #print(predict_vector)
     cm = ConfusionMatrix(actual_vector=actual_vector,
                          predict_vector=predict_vector)
     #print(cm)
     cm.save_csv(filename)
        Xts,
        yts,
        # normalize='pred',
        display_labels=labelNames,
        xticks_rotation=40,
        include_values=True,
        values_format='d',
        # values_format='.2f',
        cmap='RdPu',
        ax=ax2)

    fname = savingPath + type(clf).__name__ + '_idx_{0}'.format(i)
    saveFig(fig1, fname + 'predNormalized')
    saveFig(fig2, fname + 'Direct')
    cm = ConfusionMatrix(yts, y_pred)
    cm.save_csv(fname)

    with open(fname + '_overallStat.csv', 'w+', newline="") as csv_file:
        writer = csv.writer(csv_file)
        for key, value in cm.overall_stat.items():
            writer.writerow([key, value])

    # plt.figure()
    # plt.hist(yts,bins=len(classes))

#        thisClass=np.where(yts==i)[0]
#
#
#
#    1/0
#
X_test = np.load(input_testdata_path + "610" + ".npz")
y_test = np.load(output_testdata_path + "610" + ".npy")

X_test = X_test['arr_0']

print(np.shape(X_test))

data = model.predict_classes(X_test)
#print(np.shape(data))
#print(np.shape(y_test))

a, b = np.where(y_test == 1)

actual_array = np.empty(260)
predicted_array = np.empty(260)

actual_array = b
predicted_array = data

plot_model(
    model,
    show_shapes=True,
)

# Plot non-normalized confusion matrix
cm = ConfusionMatrix(actual_array, predicted_array)

print(cm)

cm.save_csv('confusion_matrix')