Commit 7194cb6e authored by Sarah Garcin's avatar Sarah Garcin

adding the count and probabilities numbers

parent c07b9080
......@@ -20,7 +20,7 @@ from joblib import dump, load
MODELFILE = 'classifying-the-world.joblib' # change to gz for compression
DATAFILE = 'wikipedia.csv'
stop_words = ["un", "une", "me", "cette", "alors", "au", "aussi", "autre", "avant", "avec", "avoir", "bon", "car", "ce", "cela", "ces", "ceux", "chaque", "ci", "comme", "comment", "dans", "des", "du", "de", "dedans", "dehors", "depuis", "devrait", "doit", "donc", "dos", "début", "elle", "elles", "en", "encore", "est", "et", "eu", "fait", "faites", "fois", "font", "hors", "ici", "il", "ils", "je", "juste", "la", "le", "les", "leur", "là", "ma", "maintenant", "mais", "mes", "mine", "moins", "mon", "mot", "même", "ni", "ne", "nommés", "notre", "nous", "ou", "où", "par", "parce", "pas", "peut", "peu", "plupart", "pour", "pourquoi", "quand", "que", "quel", "quelle", "quelles", "quels", "qui", "sa", "sans", "ses", "seulement", "si", "sien", "son", "sont", "sous", "soyez", "sujet", "sur", "ta", "tandis", "tellement", "tels", "tes", "ton", "tous", "tout", "trop", "très", "tu", "voient", "vont", "votre", "vous", "vu", "ça", "étaient", "état", "étions", "été", "être"]
stop_words = ["un", "une", "me", "se", "cette", "alors", "au", "aussi", "autre", "avant", "avec", "avoir", "bon", "car", "ce", "cela", "ces", "ceux", "chaque", "ci", "comme", "comment", "dans", "des", "du", "de", "dedans", "dehors", "depuis", "devrait", "doit", "donc", "dos", "début", "elle", "elles", "en", "encore", "est", "et", "eu", "fait", "faites", "fois", "font", "hors", "ici", "il", "ils", "je", "juste", "la", "le", "les", "leur", "là", "ma", "maintenant", "mais", "mes", "mine", "moins", "mon", "mot", "même", "ni", "ne", "nommés", "notre", "nous", "ou", "où", "par", "parce", "pas", "peut", "peu", "plupart", "pour", "pourquoi", "quand", "que", "quel", "quelle", "quelles", "quels", "qui", "sa", "sans", "ses", "seulement", "si", "sien", "son", "sont", "sous", "soyez", "sujet", "sur", "ta", "tandis", "tellement", "tels", "tes", "ton", "tous", "tout", "trop", "très", "tu", "voient", "vont", "votre", "vous", "vu", "ça", "étaient", "état", "étions", "été", "être"]
def trainClassifier ():
#Loading the data which is from Kaggle
......
......@@ -13,6 +13,10 @@
font-family:'anka', monospace;
}
h1{
text-align: center;
}
main {
display: flex;
flex-direction: column;
......@@ -89,7 +93,7 @@
margin-bottom: 0.5em;
cursor: pointer;
border: 1px solid #000;
position:relative
}
......@@ -105,14 +109,102 @@
.prediction-class:hover, .prediction-class.active {
color: blue;
}
.prediction-class::after{
content: "Cliquez sur une autre catégorie pour voir les résultats de chaque mot";
position:absolute;
opacity:0;
transition: opacity 0.2s linear;
width: 200px;
font-size: 12px;
background-color: blue;
color: #FFF;
padding: 5px 0;
z-index: 999;
top: -1px;
right:-205px;
// transform:translateX(-50%);
pointer-events: none;
}
.prediction-class:hover::after{
opacity:1;
}
.token {
display: inline-block;
padding: 0 .5em;
vertical-align: middle;
transition: font-size .25s;
transition: all .25s;
position: relative;
margin-bottom: 50px;
}
.token p{
font-size: 13px;
position:absolute;
text-align: center;
width: 100%;
background: #FFF;
}
.token p.prob-number{
top: 70%;
left: 0;
cursor: pointer;
}
.token p.count-number{
top: -28px;
left: 0;
cursor: pointer;
}
.token p.prob-number:hover, .token p.count-number:hover{
color: blue;
}
.token p.prob-number::after{
content: "Probabilité que le mot appartienne à cette catégorie, 0 étant la plus grand probabilité";
position:absolute;
opacity:0;
transition: opacity 0.2s linear;
width: 200px;
font-size: 12px;
background-color: blue;
color: #FFF;
padding: 5px 0;
z-index: 999;
top: -1px;
right:-205px;
// transform:translateX(-50%);
pointer-events: none;
}
.token p.prob-number:hover::after{
opacity:1;
}
.token p.count-number::after{
content: "Nombre de fois que le mot apparait dans cette catégorie dans le jeu de données";
position:absolute;
opacity:0;
transition: opacity 0.2s linear;
width: 200px;
font-size: 12px;
background-color: blue;
color: #FFF;
padding: 5px 0;
z-index: 999;
top: -1px;
right:-205px;
// transform:translateX(-50%);
pointer-events: none;
}
.token p.count-number:hover::after{
opacity:1;
}
.token[data-weight="unknown"] {
/**
* Unseen token
......
......@@ -126,6 +126,7 @@
weights = [],
classIdx = state.activeClass,
tokenEls = tokenContainer.querySelectorAll('.token');
var counts = [];
state.prediction.tokens.forEach(function (token) {
// var weight = ('counts' in token) ? token['counts'][classIdx] : null;
......@@ -137,6 +138,9 @@
min = Math.min(min, weight);
max = Math.max(max, weight);
}
// add count number to array
var count = ('counts' in token) ? token['counts'][classIdx] : null;
counts.push(count);
});
......@@ -148,10 +152,23 @@
var size = ((weight - min) / (max - min)) + .5;
tokenEl.dataset.weight = weight;
tokenEl.style.fontSize = (size * 100).toString() + '%';
var displayWeight = document.createElement("p");
displayWeight.classList.add('prob-number');
displayWeight.innerHTML = Number((weight).toFixed(3));
tokenEl.appendChild(displayWeight);
} else {
tokenEl.dataset.weight = 'unknown';
tokenEl.style.fontSize = 'initial';
}
// adding the count number
var count = counts[idx];
if (count !== null) {
var displayCount = document.createElement("p");
displayCount.classList.add('count-number');
displayCount.innerHTML = Number((count).toFixed(3));
tokenEl.appendChild(displayCount);
}
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment