Skip to content

Commit 27ac318

Browse files
author
minjk-bl
committed
Fix evaluation
1 parent b3de85b commit 27ac318

File tree

2 files changed

+48
-30
lines changed

2 files changed

+48
-30
lines changed

html/m_ml/evaluation.html

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
</div>
2424
</div>
2525
<div class="vp-grid-border-box">
26-
<label for="featureData" class="vp-orange-text">Evaluation Metrics</label>
26+
<label for="featureData">Evaluation Metrics</label>
2727
<div class="vp-grid-box vp-eval-box vp-eval-rgs">
2828
<label><input type="checkbox" id="r_squared" class="vp-state" checked><span>R squared</span></label>
2929
<label><input type="checkbox" id="mae" class="vp-state"><span>Mean Absolute Error</span></label>
@@ -40,27 +40,27 @@
4040
<label><input type="checkbox" id="recall" class="vp-state"><span>Recall</span></label>
4141
<label><input type="checkbox" id="f1_score" class="vp-state"><span>F1-scorev</label>
4242
<hr style="margin: 5px;"/>
43-
<label><input type="checkbox" id="roc_curve" class="vp-eval-check vp-state"><span>ROC Curve</span></label>
44-
<label><input type="checkbox" id="auc" class="vp-eval-check vp-state"><span>AUC</span></label>
45-
<div class="vp-ev-model vp-grid-col-95">
43+
<label><input type="checkbox" id="roc_curve" class="vp-eval-check vp-state" data-type="roc-auc"><span>ROC Curve</span></label>
44+
<label><input type="checkbox" id="auc" class="vp-eval-check vp-state" data-type="roc-auc"><span>AUC</span></label>
45+
<div class="vp-grid-col-95">
4646
<label for="model" class="vp-orange-text">Model</label>
47-
<select id="model" class="vp-select vp-state">
47+
<select id="model" class="vp-select vp-state vp-ev-model roc-auc">
4848
<!-- Auto create -->
4949
</select>
5050
</div>
5151
</div>
5252
<div class="vp-grid-box vp-eval-box vp-eval-cls">
53-
<label><input type="checkbox" id="silhouetteScore" class="vp-state" checked><span>Silhouette score</span></label>
54-
<div class="vp-ev-model vp-grid-col-95">
55-
<label for="featureData2">Feature Data</label>
56-
<input type="text" class="vp-input vp-state" id="featureData2" placeholder="Input feature data" value="X"/>
53+
<label><input type="checkbox" id="silhouetteScore" class="vp-eval-check vp-state" data-type="silhouette" checked><span>Silhouette score</span></label>
54+
<div class="vp-grid-col-95">
55+
<label for="featureData2" class="vp-orange-text">Feature Data</label>
56+
<input type="text" class="vp-input vp-state vp-ev-model silhouette" id="featureData2" placeholder="Input feature data" value="X"/>
5757
</div>
5858
<hr style="margin: 5px;"/>
59-
<label><input type="checkbox" id="ari" class="vp-state"><span>ARI (Adjusted Random Score)</span></label>
60-
<label><input type="checkbox" id="nmi" class="vp-state"><span>NMI (Normalized Mutual Information)</span></label>
61-
<div class="vp-ev-model vp-grid-col-95">
62-
<label for="targetData2">Target Data</label>
63-
<input type="text" class="vp-input vp-state" id="targetData2" placeholder="Input target data" value="y"/>
59+
<label><input type="checkbox" id="ari" class="vp-eval-check vp-state" data-type="ari-nmi"><span>ARI (Adjusted Random Score)</span></label>
60+
<label><input type="checkbox" id="nmi" class="vp-eval-check vp-state" data-type="ari-nmi"><span>NMI (Normalized Mutual Information)</span></label>
61+
<div class="vp-grid-col-95">
62+
<label for="targetData2" class="vp-orange-text">Target Data</label>
63+
<input type="text" class="vp-input vp-state vp-ev-model ari-nmi" id="targetData2" placeholder="Input target data" value="y"/>
6464
</div>
6565
</div>
6666
</div>

js/m_ml/evaluation.js

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,24 +77,36 @@ define([
7777

7878
} else if (modelType == 'clf') {
7979
// Classification - model selection
80-
if (that.checkToShowModel() == true) {
81-
$(that.wrapSelector('.vp-ev-model')).show();
80+
if (that.checkToShowModel('roc-auc') == true) {
81+
$(that.wrapSelector('.vp-ev-model.roc-auc')).prop('disabled', false);
82+
} else {
83+
$(that.wrapSelector('.vp-ev-model.roc-auc')).prop('disabled', true);
8284
}
8385
} else {
8486
// Clustering
85-
87+
if (that.checkToShowModel('silhouette') == true) {
88+
$(that.wrapSelector('.vp-ev-model.silhouette')).prop('disabled', false);
89+
} else {
90+
$(that.wrapSelector('.vp-ev-model.silhouette')).prop('disabled', true);
91+
}
92+
if (that.checkToShowModel('ari-nmi') == true) {
93+
$(that.wrapSelector('.vp-ev-model.ari-nmi')).prop('disabled', false);
94+
} else {
95+
$(that.wrapSelector('.vp-ev-model.ari-nmi')).prop('disabled', true);
96+
}
8697
}
8798
});
8899

89100
// open model selection show
90101
$(this.wrapSelector('.vp-eval-check')).on('change', function() {
91102
let checked = $(this).prop('checked');
103+
let type = $(this).data('type');
92104

93105
if (checked) {
94-
$(that.wrapSelector('.vp-ev-model')).show();
106+
$(that.wrapSelector('.vp-ev-model.' + type)).prop('disabled', false);
95107
} else {
96-
if (that.checkToShowModel() == false) {
97-
$(that.wrapSelector('.vp-ev-model')).hide();
108+
if (that.checkToShowModel(type) == false) {
109+
$(that.wrapSelector('.vp-ev-model.' + type)).prop('disabled', true);
98110
}
99111
}
100112
});
@@ -104,8 +116,8 @@ define([
104116
* Check if anything checked available ( > 0)
105117
* @returns
106118
*/
107-
checkToShowModel() {
108-
let checked = $(this.wrapSelector('.vp-eval-check:checked')).length;
119+
checkToShowModel(type) {
120+
let checked = $(this.wrapSelector('.vp-eval-check[data-type="' + type + '"]:checked')).length;
109121
if (checked > 0) {
110122
return true;
111123
}
@@ -140,13 +152,13 @@ define([
140152

141153
varSelector = new VarSelector2(this.wrapSelector(), ['DataFrame', 'list', 'str']);
142154
varSelector.setComponentID('featureData2');
143-
varSelector.addClass('vp-state vp-input');
155+
varSelector.addClass('vp-state vp-input vp-ev-model silhouette');
144156
varSelector.setValue(this.state.featureData2);
145157
$(page).find('#featureData2').replaceWith(varSelector.toTagString());
146158

147159
varSelector = new VarSelector2(this.wrapSelector(), ['DataFrame', 'list', 'str']);
148160
varSelector.setComponentID('targetData2');
149-
varSelector.addClass('vp-state vp-input');
161+
varSelector.addClass('vp-state vp-input vp-ev-model ari-nmi');
150162
varSelector.setValue(this.state.targetData2);
151163
$(page).find('#targetData2').replaceWith(varSelector.toTagString());
152164

@@ -205,15 +217,21 @@ define([
205217
$(page).find('.vp-upper-box.' + this.state.modelType).show();
206218

207219
if (this.state.modelType == 'rgs') {
208-
220+
// Regression
221+
209222
} else if (this.state.modelType == 'clf') {
210-
if (this.state.roc_curve == true || this.state.auc == true) {
211-
$(page).find('.vp-ev-model').show();
212-
} else {
213-
$(page).find('.vp-ev-model').hide();
223+
// Classification
224+
if (this.state.roc_curve == false && this.state.auc == false) {
225+
$(page).find('.vp-ev-model.roc-auc').prop('disabled', true);
214226
}
215227
} else {
216-
$(page).find('.vp-ev-model').hide();
228+
// Clustering
229+
if (this.state.silhouetteScore == false) {
230+
$(page).find('.vp-ev-model.silhouette').prop('disabled', true);
231+
}
232+
if (this.state.ari == false && this.state.nmi == false) {
233+
$(page).find('.vp-ev-model.ari-nmi').prop('disabled', true);
234+
}
217235
}
218236

219237
return page;

0 commit comments

Comments
 (0)