In [1]:
import numpy as np
import pandas as pd
import pickle
%load_ext autoreload
%autoreload 2
%matplotlib inline
import matplotlib.pyplot as plt
import sys
sys.path.append('../')
import scripts.map_and_average as mapper
import scripts.classification as classification
In [ ]:
print "mapping..."
data_list, pcadata_list, ldadata_list, nmfdata_list, ssnmfdata_list, classlabs, audiolabs = mapper.map_and_average_frames(min_variance=0.99)
mapper.write_output(data_list, pcadata_list, ldadata_list, nmfdata_list, ssnmfdata_list, classlabs, audiolabs)
In [ ]:
df_results = classification.classify_for_filenames(file_list=mapper.OUTPUT_FILES)
Sort results by accuracy of all features ('All' - Column 2)
In [6]:
df_results_sorted = df_results.sort_values(2, ascending=False, inplace=False)
df_results_sorted.head()
print df_results_sorted.to_latex(index=False)
According to results above, best classifier = LDA and best transformation = LDA.
In [7]:
CF, labels = classification.confusion_matrix_for_dataset(mapper.OUTPUT_FILES[0],
classifier='LDA')
Export the confusion matrix into .csv because it is too large (137 x 137) to visualise.
In [ ]:
np.savetxt('../data/confusion_matrix_labels.csv', labels, fmt='%s')
np.savetxt('../data/confusion_matrix.csv', CF, fmt='%10.5f')
Use the figure functionality to zoom in the confusion matrix.
In [6]:
%matplotlib notebook
plt.figure(figsize=(15, 15))
classification.plot_CF(CF, labels=labels)
In [ ]: