Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
sync with qati/GSOC16/src
  • Loading branch information
qati committed Sep 19, 2016
commit 557652d73491d447dabdd2406b647869d37e49d4
16 changes: 12 additions & 4 deletions bindings/pyroot/JsMVA/js/JsMVA.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@
});
};

JsMVA.drawTrainingTestingErrors = function(divid, dat_json){
var obj = JSROOT.parse(dat_json);
JSROOT.draw(divid, obj);
var drawLabel = function(divid, obj){
require(['d3'], function(d3){
var csvg = d3.select("#"+divid+">.interactivePlot_Labels")[0][0];
if (csvg!=null) return;
var div = d3.select("#"+divid).style("position", "relative");
var svg = div.append("svg")
var svg = div.append("svg").attr("class", "interactivePlot_Labels")
.attr("width", "200px")
.attr("height", "50px")
.style({"position":"absolute", "top": "8px", "right": "8px"});
Expand Down Expand Up @@ -106,9 +106,17 @@
});
};


JsMVA.drawTrainingTestingErrors = function(divid, dat_json){
var obj = JSROOT.parse(dat_json);
JSROOT.draw(divid, obj);
drawLabel(divid, obj);
};

JsMVA.updateTrainingTestingErrors = function(divid, dat_json){
var obj = JSROOT.parse(dat_json);
JSROOT.redraw(divid, obj);
drawLabel(divid, obj);
};

return JsMVA;
Expand Down
2 changes: 1 addition & 1 deletion bindings/pyroot/JsMVA/js/JsMVA.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions bindings/pyroot/JsMVA/python/JsMVA/DataLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def GetInputVariableHist(dl, className, variableName, numBin, processTrfs=""):
transformed = trf.CalcTransformations(inputEvents, 1)
else:
tmp = trf.CalcTransformations(transformed, 1)
del transformed[:]
del transformed
transformed = tmp

if transformed!=0:
Expand Down Expand Up @@ -82,10 +82,15 @@ def DrawCorrelationMatrix(dl, className):
# @param dl The object pointer
# @param variableName string containing the variable name
# @param numBin for creating the histogram
# @param processTrfs string containing the list of transformations to be used on input variable; eg. "I;N;D;P;U;G,D"
def DrawInputVariable(dl, variableName, numBin=100, processTrfs=""):
sig = GetInputVariableHist(dl, "Signal", variableName, numBin, processTrfs)
bkg = GetInputVariableHist(dl, "Background", variableName, numBin, processTrfs)
# @param processTrfs list of transformations to be used on input variable; eg. ["I", "N", "D", "P", "U", "G"]"
def DrawInputVariable(dl, variableName, numBin=100, processTrfs=[]):
processTrfsSTR = ""
if len(processTrfs)>0:
for o in processTrfs:
processTrfsSTR += str(o) + ";"
processTrfsSTR = processTrfsSTR[:-1]
sig = GetInputVariableHist(dl, "Signal", variableName, numBin, processTrfsSTR)
bkg = GetInputVariableHist(dl, "Background", variableName, numBin, processTrfsSTR)
c, l = JPyInterface.JsDraw.sbPlot(sig, bkg, {"xaxis": sig.GetTitle(),
"yaxis": "Number of events",
"plot": "Input variable: "+sig.GetTitle()})
Expand Down
21 changes: 16 additions & 5 deletions bindings/pyroot/JsMVA/python/JsMVA/Factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,27 +633,38 @@ def ChangeCallOriginalEvaluateImportance(*args, **kwargs):
return originalFunction(*args)
args, kwargs = JPyInterface.functions.ConvertSpecKwargsToArgs(["DataLoader", "VIType", "Method", "MethodTitle"], *args, **kwargs)
originalFunction, args = JPyInterface.functions.ProcessParameters(5, *args, **kwargs)
return originalFunction(*args)
hist = originalFunction(*args)
JPyInterface.JsDraw.Draw(hist)
return hist

## Rewrite the constructor of TMVA::Factory::CrossValidate
def ChangeCallOriginalCrossValidate(*args, **kwargs):
if len(kwargs) == 0:
originalFunction, args = JPyInterface.functions.ProcessParameters(0, *args, **kwargs)
return originalFunction(*args)
optParams = False
rocIntegrals = False
NumFolds = 5
remakeDataSet = True
rocIntegrals = None
if "optParams" in kwargs:
optParams = kwargs["optParams"]
del kwargs["optParams"]
if "NumFolds" in kwargs:
NumFolds = kwargs["NumFolds"]
del kwargs["NumFolds"]
if "remakeDataSet" in kwargs:
remakeDataSet = kwargs["remakeDataSet"]
del kwargs["remakeDataSet"]
if "rocIntegrals" in kwargs:
rocIntegrals = kwargs["rocIntegrals"]
del kwargs["rocIntegrals"]
args, kwargs = JPyInterface.functions.ConvertSpecKwargsToArgs(["DataLoader", "Method", "MethodTitle"], *args, **kwargs)
originalFunction, args = JPyInterface.functions.ProcessParameters(4, *args, **kwargs)
args = list(args)
if optParams!=False:
args.append(optParams)
if rocIntegrals!=False:
args.append(optParams)
args.append(NumFolds)
args.append(remakeDataSet)
if rocIntegrals!=None and rocIntegrals!=0:
args.append(rocIntegrals)
args = tuple(args)
return originalFunction(*args)
13 changes: 10 additions & 3 deletions bindings/pyroot/JsMVA/python/JsMVA/JPyInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,15 @@ def ProcessParameters(optStringStartIndex, *args, **kwargs):
elif type(kwargs[key]) == types.ListType:
ss = ""
for o in kwargs[key]:
ss += str(o) + ";"
if type(o) == types.DictType:
sst = ""
for kk in o:
sst += kk + "=" + str(o[kk]) + ","
ss += sst[:-1] + "|"
elif key=="Layout":
ss += str(o) + ","
else:
ss += str(o) + ";"
opt += key + "=" + ss[:-1] + ":"
else:
opt += key + "=" + str(kwargs[key]) + ":"
Expand Down Expand Up @@ -153,8 +161,7 @@ def unregister():
## Class for creating the output scripts and inserting them to cell output
class JsDraw:
## String containing the link to JavaScript files
#__jsMVASourceDir = "https://rawgit.com/qati/GSOC16/master/src/js"
__jsMVASourceDir = "http://localhost:8888/notebooks/GSOC/wd/src/js"
__jsMVASourceDir = "https://rawgit.com/qati/GSOC16/master/src/js"

## Drawing are sizes
jsCanvasWidth = 800
Expand Down