Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

Commit 94122987 authored by Anze Vavpetic's avatar Anze Vavpetic
Browse files

Roc hulls and points now appear with the same color. Added nicer tooltips.

parent 0ab54a0d
......@@ -10,8 +10,6 @@ def calcRates(subgroups):
# subgroups.TPR = [0.44, 0.34, 0.33, 0.49, 0.43, 0.49, 0.66, 0.60, 0.61, 0.78, 0.75, 0.77, 0.84, 0.82, 0.82]
# subgroups.FPR = [0.01, 0.00, 0.00, 0.02, 0.00, 0.02, 0.10, 0.07, 0.07, 0.21, 0.16, 0.19, 0.31, 0.29, 0.27]
len(subgroups.TPR)
# calculate convex hull ,important: stick this 5 linet together
subgroups.hullTPR = [0]
subgroups.hullFPR = [0]
......
......@@ -20,4 +20,24 @@ def build_subgroups(request, input_dict, output_dict, widget):
'all_parameters' : json.dumps(SubgroupDiscovery.parameter_info.keys()),
'settings' : json.dumps(SubgroupDiscovery.algorithms),
'className' : className,
'classValues' : classValues})
\ No newline at end of file
'classValues' : classValues})
def subgroup_bar_visualization(request, input_dict, output_dict, widget):
'''
Subgroup bar visualization.
@author: Anze Vavpetic, 2012
'''
sd_rules = input_dict['rules']
rules = sd_rules.rules
P, N = float(len(sd_rules.targetClassRule.TP)), float(len(sd_rules.targetClassRule.FP))
fpr = [-len(rule.FP)/N for rule in rules]
tpr = [len(rule.TP)/P for rule in rules]
subgroups = [rule.ruleToString() for rule in rules]
return render(request, 'visualizations/subgroup_bar_visualization.html', {
'widget' : widget,
'model_name' : sd_rules.algorithmName,
'fpr' : json.dumps(fpr),
'tpr' : json.dumps(tpr),
'subgroups' : json.dumps(subgroups)
})
\ No newline at end of file
......@@ -52,5 +52,9 @@ def build_subgroups_finished(postdata, input_dict, output_dict):
def subgroup_bar_visualization(input_dict):
return {'rules' : None}
def subgroup_bar_finished(postdata, input_dict, output_dict):
# Todo
return None
def subgroup_roc_visualization(input_dict):
return {'rules' : []}
\ No newline at end of file
......@@ -5,28 +5,9 @@ Subgroup discovery visualization views.
'''
from django.shortcuts import render
import json
import colorsys
from SubgroupDiscovery.calcHull import calcRates
def subgroup_bar_visualization(request, input_dict, output_dict, widget):
'''
Subgroup bar visualization.
@author: Anze Vavpetic, 2012
'''
sd_rules = input_dict['rules']
rules = sd_rules.rules
P, N = float(len(sd_rules.targetClassRule.TP)), float(len(sd_rules.targetClassRule.FP))
fpr = [-len(rule.FP)/N for rule in rules]
tpr = [len(rule.TP)/P for rule in rules]
subgroups = [rule.ruleToString() for rule in rules]
return render(request, 'visualizations/subgroup_bar_visualization.html', {
'widget' : widget,
'model_name' : sd_rules.algorithmName,
'fpr' : json.dumps(fpr),
'tpr' : json.dumps(tpr),
'subgroups' : json.dumps(subgroups)
})
def subgroup_roc_visualization(request, input_dict, output_dict, widget):
'''
Subgroup roc visualization.
......@@ -34,12 +15,14 @@ def subgroup_roc_visualization(request, input_dict, output_dict, widget):
@author: Anze Vavpetic, 2012
'''
roc_data = []
n = len(input_dict['rules'])
colors = ['#%2x%2x%2x' % tuple(map(lambda c: 255 * c, colorsys.hsv_to_rgb(x / float(n), 0.5, 0.8))) for x in range(n)]
for i, sd_rules in enumerate(input_dict['rules']):
P, N = float(len(sd_rules.targetClassRule.TP)), float(len(sd_rules.targetClassRule.FP))
calcRates(sd_rules)
rule_points = [{'x' : len(rule.FP)/N, 'y' : len(rule.TP)/P, 'name' : rule.ruleToString()} for rule in sd_rules.rules]
roc_data.append({'type': 'line', 'name' : sd_rules.algorithmName, 'data' : zip(sd_rules.hullFPR, sd_rules.hullTPR)})
#roc_data.append({'type': 'scatter', 'name' : sd_rules.algorithmName, 'data' : rule_points})
roc_data.append({'type': 'line', 'name' : sd_rules.algorithmName + ' (hull)', 'color' : colors[i], 'zIndex' : 0, 'data' : zip(sd_rules.hullFPR, sd_rules.hullTPR)})
roc_data.append({'type': 'scatter', 'name' : sd_rules.algorithmName, 'color' : colors[i], 'zIndex' : 1, 'data' : rule_points})
return render(request, 'visualizations/subgroup_roc_visualization.html', {
'widget' : widget,
'roc_data' : json.dumps(roc_data),
......
......@@ -35,6 +35,15 @@
min: 0.0,
max: 1.0
},
tooltip: {
// TODO! display subgroup description for each point as well as TP/FP
formatter: function() {
// Display the subgroup description if there is one
var description = (this.point.name != null ? this.point.name : '');
return ''+
this.series.name + ': ' + description + '\nFP = ' + Math.abs(this.x.toFixed(3)) +' TP = '+ Math.abs(this.y.toFixed(3));
}
},
series: {{roc_data|safe}},
credits: {
enabled: false
......
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