示例#1
0
def mpPlot():
    listFiles = ut_service.getListLC_test()
    if request.method == 'POST':
        fileName = str(request.form.get('selectFile'))
        inputDuration = int(request.form.get('inputDuration'))
        inputHeight = int(request.form.get('inputHeight'))
        subsequence_length = int(request.form.get('input_subsequence_length'))
        rawInstances, transList = ut_service.getDataLC_test(
            fileName, L=int(inputHeight), I=int(inputDuration))
        x_axis = list(range(len(rawInstances)))
        mp_list = ut_gen.genMartixProfile(
            instances=rawInstances,
            timestamp=x_axis,
            subsequence_length=subsequence_length)
        xmin = min(mp_list)
        xmax = max(mp_list)
        for i, x in enumerate(mp_list):
            mp_list[i] = (x - xmin) / (xmax - xmin)
        data = {"instances": rawInstances, "timestamp": x_axis}
        js, div = ut_exBok.export_JsDiv_RawMP(data=data,
                                              mp_list=mp_list,
                                              isUTC=False)
        return render_template("html/mp/mp_test_plot.html",
                               js=js,
                               div=div,
                               file_name=fileName)
示例#2
0
def rrcfPlot():
    listFiles = ut_service.getListLC_test()
    if request.method == 'POST':
        fileName = str(request.form.get('selectFile'))
        inputDuration = int(request.form.get('inputDuration'))
        inputHeight = int(request.form.get('inputHeight'))
        rawInstances, transList = ut_service.getDataLC_test(
            fileName, L=int(inputHeight), I=int(inputDuration))
        x_axis = list(range(len(rawInstances)))
        rrcf_resultList = ut_gen.getRRCFresult(fileName=fileName,
                                               duration=inputDuration,
                                               height=inputHeight)
        rrcf = {
            "instances": rrcf_resultList,
            "timestamp": x_axis[0:len(rrcf_resultList)]
        }
        data = {"instances": rawInstances, "timestamp": x_axis}
        js, div = ut_exBok.export_JsDiv_Single(data=data,
                                               legend="RAW",
                                               color='black',
                                               isCircle=True)
        jsRRCF, divRRCF = ut_exBok.export_JsDiv_Single(data=rrcf,
                                                       legend="RRCF",
                                                       color='red',
                                                       isCircle=True)
        return render_template("html/rrcf/rrcf_test_plot.html",
                               js=js,
                               div=div,
                               jsRRCF=jsRRCF,
                               divRRCF=divRRCF,
                               file_name=fileName)
示例#3
0
def xmeanPlot():
    listFiles = ut_service.getListLC_test()
    if request.method == 'POST':
        fileName = str(request.form.get('selectFile'))

        amount_initial_centers = int(
            request.form.get('amount_initial_centers'))
        kmax = int(request.form.get('kmax'))

        FdataMDF, FtimestampMDF = ut_service.getMDFData(fileName)
        resultDic = ut_cluster.cluster_xMean(
            listInput=FdataMDF,
            amount_initial_centers=amount_initial_centers,
            kmax=kmax)
        TOOLTIPS = [
            ("index", "$index"),
            ("(x,y)", "@x{0,0.000000}, $y"),
        ]
        js, div = ut_bokeh.JSandDivXMeanPlot(x_axis=FtimestampMDF,
                                             y_axisRaw=FdataMDF,
                                             resultDic=resultDic,
                                             title=fileName,
                                             TOOLTIPS=TOOLTIPS)
        # js, div = ut_bokeh.JSandDivDoublePlot(x_axis=FtimestampMDF, y_axisRaw=FdataMDF, y_axisBin=sketchInstances,
        #                                       title=fileName, transList=transList,alarmList=alarmList)
        #
        # rows = corePlot.getDataTableMeanVarianceBin()
        return render_template("html/LC_test/lc_test_plot.html",
                               jsResult=js,
                               divResult=div,
                               listFiles=listFiles)
示例#4
0
def lcFixPlot():
    listFiles = ut_service.getListLC_test()
    if request.method == 'POST':
        fileName = str(request.form.get('selectFile'))
        inputDuration = int(request.form.get('inputDuration'))
        inputHeight = int(request.form.get('inputHeight'))

        windowSize = int(request.form.get('inputWindowSize'))

        rawInstances, transList = ut_service.getDataLC_test(
            fileName, L=int(inputHeight), I=int(inputDuration))
        x_axis = list(range(len(rawInstances)))

        data = {
            "instances": rawInstances,
            "timestamp": x_axis,
            "fileName": fileName,
            "windowSize": windowSize
        }
        sketchInstances = ut_gen.genFixBin(binSize=windowSize,
                                           instances=rawInstances)

        add_on = []
        for tran in transList:
            add_on.append({
                'type': 'anwser',
                'start': int(tran[0]),
                'end': int(tran[1])
            })

        # js, div = ut_exBok.export_JsDiv_saxcompare(data=data, add_on=add_on)
        #
        js, div = ut_bokeh.JSandDivDoublePlotStandard(
            x_axis=x_axis,
            y_axisRaw=rawInstances,
            y_axisBin=sketchInstances,
            title=fileName,
            add_on=add_on,
            legend_label='Fixed')

        rows = []
        return render_template("html/LC_test/lc_test_plot.html",
                               jsResult=js,
                               divResult=div,
                               listFiles=listFiles,
                               rows=rows)
示例#5
0
def lcPlot():
    listFiles = ut_service.getListLC_test()
    if request.method == 'POST':
        fileName = str(request.form.get('selectFile'))
        inputDuration = int(request.form.get('inputDuration'))
        inputHeight = int(request.form.get('inputHeight'))

        windowSize = int(request.form.get('inputWindowSize'))
        initialBin = int(request.form.get('inputInitialBin'))

        rawInstances, transList = ut_service.getDataLC_test(
            fileName, L=int(inputHeight), I=int(inputDuration))
        x_axis = list(range(len(rawInstances)))
        corePlot = sketchDyBinService(windowSize=windowSize,
                                      initialBin=initialBin,
                                      isOnline=False)
        sketchInstances = corePlot.sketchMode(instances=rawInstances)

        dictResult = corePlot.getListResultTest()
        threshold_tTest = float(request.form.get('threshold_tTest'))
        if threshold_tTest == 0:
            alarmList = []
        else:
            alarmList = ut_service.genTranFromTtest(
                dictResult=dictResult, threshold_tTest=threshold_tTest)

        js, div = ut_bokeh.JSandDivDoublePlotWithToggle(
            x_axis=x_axis,
            y_axisRaw=rawInstances,
            y_axisBin=sketchInstances,
            title=fileName,
            transList=transList,
            alarmList=alarmList)

        rows = corePlot.getDataTableMeanVarianceBin()
        return render_template("html/LC_test/lc_test_plot.html",
                               jsResult=js,
                               divResult=div,
                               listFiles=listFiles,
                               rows=rows)
示例#6
0
def rrcfMain():
    listFiles = ut_service.getListLC_test()
    return render_template("html/rrcf/lc_rrcf_main.html", listFiles=listFiles)
示例#7
0
def mpMain():
    listFiles = ut_service.getListLC_test()
    return render_template("html/mp/lc_mp_main.html", listFiles=listFiles)
示例#8
0
def lcMain():
    listFiles = ut_service.getListLC_test()
    return render_template("html/LC_test/lc_test_main.html",
                           listFiles=listFiles)
lc_path_answer = "sq_L{}_I{}\\answer\\".format(L, I)

path_to_lc_data_file = "{}{}".format(dataset_path, lc_path_test)
path_to_lc_ans_file = "{}{}".format(dataset_path, lc_path_answer)


html_path = "sq_L{}_I{}\\html\\".format(L, I)
png_path = "sq_L{}_I{}\\bokeh_pic\\".format(L, I)
driver = webdriver.Chrome(executable_path="C:\\chromedriver\\chromedriver.exe")



pathHtmlOutput = "{}{}".format(dataset_path, html_path)
pathPngOutput = "{}{}".format(dataset_path, png_path)
data = {'inputWindowSize': 100, 'inputInitialBin': 3}
listFile = ut_web.getListLC_test(L=L,I=I)

for indexFile, fileName in enumerate(listFile):
    print(fileName)
    isFoundHtml = ut.isFileNameInFolder(path=pathHtmlOutput, fileName="{}.html".format(fileName))
    isFoundPng = ut.isFileNameInFolder(path=pathPngOutput, fileName="{}.png".format(fileName))
    if not (isFoundHtml & isFoundPng):
        rawInstances, transList = ut_service.getDataLC_test(fileName,L=L,I=I)

        x_axis = list(range(len(rawInstances)))

        plotRaw = ut_bokeh.exportPlot(x_axis=x_axis,
                                      y_axis=rawInstances,
                                      fileName=fileName,
                                      transList=transList)