Commit 3380c8b5 authored by Chris's avatar Chris
Browse files

"confusion matrices"

parent 470af87d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ def getTopFiveWords():

@app.route('/getConfusionMatrix', methods=["GET"])
def getConfusionMatrix():
    return ml.getConfusionMatrix();
    return ml.getConfusionMatrix()


# Run the app!
+3 −0
Original line number Diff line number Diff line
@@ -93,6 +93,9 @@
            </div>

            <br>
            <p>Confusion matrices: These values show what percent of the messages were designated as, respectively:<br>
                true negative, false positive, false positive, and true positive.
            </p>
            <div id="confusion_matrices">
                <p>Confusion matrices for each algorithm will go here</p>
            </div>
+30 −0
Original line number Diff line number Diff line
@@ -200,6 +200,7 @@ function getTopFiveWords() {
function initializeIndex() {
    getTopAlgorithms();
    getTopFiveWords();
    getConfusionMatrices();
}

// when the Clear button is pressed, clear the message textarea
@@ -239,6 +240,35 @@ function loadAlgGraph(topAlgs){
    });
}

function getConfusionMatrices() {
    var url = "http://localhost:8080"
    var endpoint = "/getConfusionMatrix"

    var http = new XMLHttpRequest();

    http.open("GET", url + endpoint, true);
    http.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');

    http.onreadystatechange = function () {
        var DONE = 4;       // 4 means that the request is done
        var OK = 200;       // 200 means a successful return

        if (http.readyState == DONE && http.status == OK && http.responseText) {
            // JSON string
            replyString = http.responseText;

            // JSON -> JS object
            replyObj = JSON.parse(replyString);

            document.getElementById("confusion_matrices").innerText = "Decision tree confusion matrix:\n" + replyObj["Decision Tree"] +
            "\nNeural Network confusion matrix:\n" + replyObj["Neural Network"] +
             "\nPerceptron confusion matrix:\n" + replyObj["Perceptron"] +
             "\nStochastic gradient descent confusion matrix:\n" + replyObj["Stochastic Gradient Descent"]
        }
    }
    http.send();
}

function loadWordGraph(topWords){

    Highcharts.chart('top_words', {