Commit b962ff5c authored by Larry Schultheis's avatar Larry Schultheis
Browse files

Word clout

parent 3380c8b5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -308,7 +308,7 @@ def partialFitNewData(message, label):

def topFive():
    features = load('features.joblib')
    return features[:5]
    return features[:25]


def switchCurrentAlgorithm():
+2 −0
Original line number Diff line number Diff line
@@ -127,6 +127,8 @@

<!-- Visualization import -->
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/wordcloud.js"></script>


<script
  src="https://code.jquery.com/jquery-3.4.1.min.js"
+45 −43
Original line number Diff line number Diff line
@@ -271,50 +271,52 @@ function getConfusionMatrices() {

function loadWordGraph(topWords){

    // var data = [{
    //     name: topWords.words[0],
    //     weight: 5
    // }, {
    //     name: topWords.words[1],
    //     weight: 4
    // }, {
    //     name: topWords.words[2],
    //     weight: 3
    // }, {
    //     name: topWords.words[3],
    //     weight: 2
    // }, {
    //     name: topWords.words[4],
    //     weight: 1
    // }]

    var data = []

    var i = 0
    var j = 100
    for (i; i < 25; i++){
        data[i] = {
            name: topWords.words[i],
            weight: j
        }
        j = j - 2
    }

    console.log(data)
    
    Highcharts.chart('top_words', {
        chart: {
            plotBackgroundColor: null,
            plotBorderWidth: null,
            plotShadow: false,
            type: 'pie'
        series: [{
            type: 'wordcloud',
            data: data,
            name: 'Weight',
            rotation: {
                from: 0,
                to: 0
            },
            spiral: 'rectangular',
            placementStrategy: 'center'
        }],
        title: {
            text: 'Top Words'
        },
        tooltip: {
            pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    format: '<b>{point.name}</b>: {point.percentage:.1f} %'
        }
            }
        },
        series: [{
            name: 'Chance of spam',
            colorByPoint: true,
            data: [{
                name: topWords.words[0],
                y: 60.0,
                sliced: true,
                selected: true
            }, {
                name: topWords.words[1],
                y: 20.0
            }, {
                name: topWords.words[2],
                y: 10.0
            }, {
                name: topWords.words[3],
                y: 5.0
            }, {
                name: topWords.words[4],
                y: 5.0
            }]
        }]
    });
    })
      
}
 No newline at end of file