diff --git a/.gitignore b/.gitignore index 590b956c97443df78931647eb92ceb65bfb8e76c..58d443c8ecf8ab0ba983557e4b0df364b6c62bc6 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,6 @@ X.npy Y.npy *.pyc -.vscode/ \ No newline at end of file +.vscode/ +/__pychache__/ +python/hf5-test.py diff --git a/Dokumentation/silas/w2vCNN.tex b/Dokumentation/silas/w2vCNN.tex index cb912e984266409235a7bffb2a97e869017c9751..936b98201a496d3d7fd21b5367d60b0517572e4b 100644 --- a/Dokumentation/silas/w2vCNN.tex +++ b/Dokumentation/silas/w2vCNN.tex @@ -1,3 +1,4 @@ +\newpage \subsection{Word2Vec-CNN-Modell} Ein \noteable{convolutional neural network}, kurz CNN, ist in der Lage, lokale Muster in einer Sequenz zu erlernen und diese später @@ -187,7 +188,7 @@ einmal durchläuft. Dieser Generator kann nun in Zeile 35 an die Methode \lstinline{evaluate} übergeben werden. Das Evaluieren zeigt das dieses Modell zu $81.44\%$ die Klassen richtig klassifiziert. -\begin{lstlisting}[caption={CNN - Klassengewichte},label={list:modelCNNWeights}] +\begin{lstlisting}[caption={CNN - Klassengewichte},label={list:modelCNNWeights},numbers=none] Y_train=[] gen = hdf5Generator(path + "w2vCNN.hdf5", batchSize, "Test",loop=False) for (x,y) in gen: @@ -197,10 +198,10 @@ count = np.unique(Y_train,return_counts=True)[1] cWeight = 1/(count/Y_train.size) \end{lstlisting} \subsubsection{Konfusionsmatrix} -Um einen besseren Eindruck über die Stärken und Schwächen des +Um einen besseren Eindruck über die Qualität des Netzes zu erhalten, wird auch bei diesem Modell wieder eine Konfusionsmatrix erstellt. -\begin{lstlisting}[caption={CNN - Konfusionsmatrix},label={list:modelCNNWeights}] +\begin{lstlisting}[caption={CNN - Konfusionsmatrix},label={list:modelCNNKonf},firstnumber=36] from sklearn.metrics import confusion_matrix tD = hdf5Generator(path + "w2vCNN.hdf5", batchSize, "Test",loop=False) y_pred = np.argmax(modelNN.predict(tD),axis=-1) @@ -211,6 +212,13 @@ y_test = np.array(y_test).flatten() confusion_matrix(y_test,y_pred,normalize='true') \end{lstlisting} +Dafür werden die vom Netz vorhergesagten Klassen der Testmenge in dem +Vektor \lstinline{y_pred} gespeichert und die tatsächlichen Klassen der Testmenge in dem +Vektor \lstinline{y_test}. Beide Vektoren werden der Funktion +\lstinline{confusion_matrix} Übergeben, +welche die in der Tabelle \ref{tab:conf_w_cnn} dargestellte Konfusionsmatrix +zurückliefert. + \begin{table}[ht] \def\arraystretch{1.3} \begin{center} @@ -224,4 +232,4 @@ confusion_matrix(y_test,y_pred,normalize='true') \label{tab:conf_w_cnn} \caption{Konfusionsmatrix mit Klassengewichtung} \end{table} - +\wip{Tabelle auswerten} diff --git a/Dokumentation/silas/w2vMean.tex b/Dokumentation/silas/w2vMean.tex index c18f5ae1e74f4be758a97c54716571b9ae2dc448..6b707ce2b4868b25a4f7b826a6b6f97aa12dc20b 100644 --- a/Dokumentation/silas/w2vMean.tex +++ b/Dokumentation/silas/w2vMean.tex @@ -1,3 +1,4 @@ +\newpage \subsection{Mean-Vektor-Klassifikationsmodell} %Durchschnittsvektor-Klassifkationsmodell ?? Das Word2Vec-Modell bildet einen Vektorraum, indem ähnliche Wörter nahe @@ -173,7 +174,6 @@ from sklearn.metrics import confusion_matrix y_pred = np.argmax(modelNN.predict(X_test),axis=-1) confusion_matrix(Y_test,y_pred,normalize='true') \end{lstlisting} -\wip{Tabelle auswerten} \begin{table}[ht] \def\arraystretch{1.3} \begin{center} @@ -185,11 +185,24 @@ confusion_matrix(Y_test,y_pred,normalize='true') \end{tabular} \end{center} \caption{Konfusionsmatrix mit Klassengewichtung} + \label{tab:m_w} \end{table} + +Wie in Tabelle \ref{tab:m_w} zu sehen ist, werden negative Bewertungen zu $80.46\%$ +richtig als negative Bewertung klassifiziert, $17.27\%$ werden als +neutral klassifiziert und $2.28\%$ werden als positiv klassifiziert. + +Neutrale Bewertungen werden zu $68.44\%$ richtig klassifiziert, +jedoch werden $16.82\%$ der neutralen Bewertungen falsch als +negative klassifiziert und zu $14.74\%$ falsch als positiv klassifiziert. + +Die positiven Bewertungen werden zu $81.72\%$ richtig als positive +Bewertungen klassifiziert, zu $15.86\%$ als neutral und zu +$2.42\%$ als negativ klassifiziert. + Das gleiche Modell ohne die Gewichtung der Klassen erreicht eine Genauigkeit von $85.7\%$, betrachtet man jedoch die Konfusionsmatrix in Tabelle \ref{tab:conf_no_w}, so sieht man das dort bloß $27\%$ der neutralen Rezensionen richtig klassifiziert wurden. -\wip{Tabellenreferenz ???} \begin{table}[ht] \def\arraystretch{1.3} \begin{center} @@ -200,6 +213,6 @@ sieht man das dort bloß $27\%$ der neutralen Rezensionen richtig klassifiziert Positiv &0.0249& 0.0235& 0.9516\\ \end{tabular} \end{center} - \label{tab:conf_no_w} \caption{Konfusionsmatrix ohne Klassengewichtung} + \label{tab:conf_no_w} \end{table} \ No newline at end of file diff --git a/Dokumentation/w2v.pdf b/Dokumentation/w2v.pdf index c5243e21487f4207c84320c850bca92f0ca255a0..947827a152cbf8a5b1faf73fe04370496151c063 100644 Binary files a/Dokumentation/w2v.pdf and b/Dokumentation/w2v.pdf differ diff --git a/python/__pycache__/w2v_yelp_model.cpython-38.pyc b/python/__pycache__/w2v_yelp_model.cpython-38.pyc deleted file mode 100644 index 436636457f2a3c21972dbdf2d5471d4255912cf4..0000000000000000000000000000000000000000 Binary files a/python/__pycache__/w2v_yelp_model.cpython-38.pyc and /dev/null differ