Skip to content
Snippets Groups Projects
Commit 072d0afd authored by Nelly Barret's avatar Nelly Barret
Browse files

[M] moved manual assessment

parent aa766a9e
No related branches found
No related tags found
No related merge requests found
Showing
with 22 additions and 86 deletions
...@@ -313,11 +313,8 @@ class Data: ...@@ -313,11 +313,8 @@ class Data:
else: self.data.to_csv(self.dataset_path, index=None) # index=None: avoid line numbering else: self.data.to_csv(self.dataset_path, index=None) # index=None: avoid line numbering
def add_manually_assessed_iris(self): def add_manually_assessed_iris(self):
print("ADD MANUAL ASSESSMENT")
manually_assessed_iris = pd.read_csv(FILE_MANUAL_ASSESSMENT_EXPERTS, header=0) manually_assessed_iris = pd.read_csv(FILE_MANUAL_ASSESSMENT_EXPERTS, header=0)
print(len(self.data))
self.data = self.data.append(manually_assessed_iris) self.data = self.data.append(manually_assessed_iris)
print(len(self.data))
self.data["CODE"] = self.data["CODE"].astype(str) self.data["CODE"] = self.data["CODE"].astype(str)
self.data.sort_values("CODE", inplace=True) self.data.sort_values("CODE", inplace=True)
self.fill_missing_values("median") self.fill_missing_values("median")
......
...@@ -104,87 +104,34 @@ function displayPopup(e) { ...@@ -104,87 +104,34 @@ function displayPopup(e) {
divInformation.append(moreInfosLink); divInformation.append(moreInfosLink);
} }
if (selected_algorithm !== "undefined" && selected_algorithm !== undefined) {
if($("#assessmentMode").is(":checked")) { predictions = predict(code_iris, selected_algorithm)
// alert("assessment mode"); console.log(predictions)
for(let env in environment_variables) {
let env_values = environment_variables[env]
let div_container = $("<div>").prop("id", "assessment"+env)
let list_values = $("<select>");
for(let value in env_values) { list_values.append($("<option>").prop("value", env_values[value]).text(env_values[value])) }
div_container.append(env).append(list_values)
divInformation.append(div_container)
}
if($("#addAssessmentButton").length > 0) {
$("#addAssessmentButton").removeAttr("id"); // remove id to avoid duplicates (fix the miss of event on button)
}
let to_csv_button = $("<button>").prop("id", "addAssessmentButton");
if(preferred_language_carto === "french") {
to_csv_button.text("Ajouter au jeu de données");
} else {
to_csv_button.text("Add to dataset");
}
let messageTooltip = divInformation[0].outerHTML + to_csv_button[0].outerHTML;
layer.bindPopup(messageTooltip)
layer.bringToFront();
layer.openPopup();
$("#addAssessmentButton").on("click", function() {
let data_param = {}
for(let env in environment_variables) {
data_param[env] = $("#assessment"+env)[0].children[0].value
}
data_param["code_iris"] = code_iris
console.log(data_param)
$.ajax({
type: "GET",
url: "/add_iris_to_csv",
data: data_param,
"async": false,
contentType: 'application/json;charset=UTF-8',
success: function(result) {
alert(result)
},
error: function(result, textStatus, errorThrown) {
console.log(errorThrown);
}
});
});
} }
else {
if (selected_algorithm !== "undefined" && selected_algorithm !== undefined) {
predictions = predict(code_iris, selected_algorithm)
console.log(predictions)
}
let selectAlgorithm = $("<select>") let selectAlgorithm = $("<select>")
selectAlgorithm selectAlgorithm
.prop("id", "selectAlgorithmTooltip") .prop("id", "selectAlgorithmTooltip")
.append($("<option>").prop("value", "undefined").text("---")) .append($("<option>").prop("value", "undefined").text("---"))
for(let algorithm of classifiers) { for(let algorithm of classifiers) {
selectAlgorithm.append($("<option>").prop("value", algorithm).text(algorithm)); selectAlgorithm.append($("<option>").prop("value", algorithm).text(algorithm));
} }
previously_selected_algorithm = selected_algorithm; previously_selected_algorithm = selected_algorithm;
let divPredictions = $("<div>").prop("id", "divPredictions") let divPredictions = $("<div>").prop("id", "divPredictions")
if(predictions !== undefined) { if(predictions !== undefined) {
for(let key in predictions) { divPredictions.append(capitalizeFirstLetter(key.split("_").join(" "))+': ' + predictions[key]["most_frequent"] + " (" + predictions[key]["count_frequent"] + "/7)").append($('<br>')); } for(let key in predictions) { divPredictions.append(capitalizeFirstLetter(key.split("_").join(" "))+': ' + predictions[key]["most_frequent"] + " (" + predictions[key]["count_frequent"] + "/7)").append($('<br>')); }
} }
let messageTooltip = divInformation[0].outerHTML + selectAlgorithm[0].outerHTML + divPredictions[0].outerHTML; let messageTooltip = divInformation[0].outerHTML + selectAlgorithm[0].outerHTML + divPredictions[0].outerHTML;
console.log(messageTooltip) console.log(messageTooltip)
layer.bindPopup(messageTooltip) layer.bindPopup(messageTooltip)
layer.bringToFront(); layer.bringToFront();
layer.openPopup(); layer.openPopup();
$("#selectAlgorithmTooltip").val(previously_selected_algorithm); // must be after binding the popup to be effective $("#selectAlgorithmTooltip").val(previously_selected_algorithm); // must be after binding the popup to be effective
$("#selectAlgorithmTooltip").on("click", function() { displayPopup(e)}) // update popup (env variables) when click on an algorithm $("#selectAlgorithmTooltip").on("click", function() { displayPopup(e)}) // update popup (env variables) when click on an algorithm
}
} }
/** /**
......
...@@ -55,14 +55,6 @@ ...@@ -55,14 +55,6 @@
<br> <br>
</div> </div>
<div>
{% if language == "french" %}
Expertise manuelle: <input type="checkbox" id="assessmentMode"/>
{% else %}
Manual assessment: <input type="checkbox" id="assessmentMode"/>
{% endif %}
</div>
<div class="input-group mb-3"> <div class="input-group mb-3">
<button class="btn" type="button" id="boutonEffacer"> <button class="btn" type="button" id="boutonEffacer">
{% if language == "french" %} {% if language == "french" %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment