Ejemplo n.º 1
0
def setFileChoice(filechoice):
    log('setFileChoice triggered')
    if isNone(filechoice):
        return []
    setFile(filechoice)
    # clearOptions()
    return []
Ejemplo n.º 2
0
 def load(filename):
     if isNone(filename):
         return None
     from os.path import join, exists
     file = join(dir_datafiles, filename)
     if not exists(file):
         return None
     return pkl.load(open(file, 'rb'))
Ejemplo n.º 3
0
def precalculate(n):
    if isNone(n):
        return nu
    exists, data = existsData()
    if not exists:
        return []
    data.precalculate()
    data.save()
    return []
Ejemplo n.º 4
0
def updateMatrixProfile(*args):
    outcol = args[-2]
    blockindex = args[-1]
    if isNone(outcol):
        return [go.Figure(), [], []]
    exists, data = existsData()
    kwargs = {}
    if not isNone(outcol):
        kwargs['outcol'] = outcol
    if not isNone(blockindex):
        kwargs['blockindex'] = blockindex
    exists, data = existsData()
    fo = f'{data.originalfilename}' if exists else []
    if exists:
        return [
            data.matrixProfileFigure(**kwargs),
            data.contrastiveExplainOutlierBlock(**kwargs), fo
        ]
Ejemplo n.º 5
0
 def explain(self, html=False):
     if isNone(self.literal[0]):
         return 'There was no explanation found by contrastive foil trees.'
     literals = [
         self.operatorcorrected[s]
         for s in np.argsort([l.feature for l in self.literal])
     ]
     literals = [self.explainLiteral(literal) for literal in literals]
     literals = " and ".join(literals) if not html else "<br />and ".join(
         literals)
     msg = ''
     if self.completeInput:
         msg = f'Predicted "{self.fact}" instead of "{self.foil}", because{"<br />" if html else ": "}{literals}'
         msg.format()
     else:
         msg = f'Decission was taken, because{"<br />" if html else ": "}{literals}'
     return msg
Ejemplo n.º 6
0
 def __init__(self,
              literal,
              features,
              fact=None,
              foil=None,
              weight=None,
              complete=False):
     assert type(literal) == Literal or isNone(literal) or (
         all([type(lit) == Literal for lit in literal]) and type(literal)
         == list), 'Only Literals are allowed. Either one Literal or a list'
     literal = literal if type(literal) == list else [literal]
     assert type(features) == list and all(
         [type(feat) == str
          for feat in features]), 'Please provide a list of features'
     self.literal = literal
     self.__features = features
     self.fact = fact
     self.foil = foil
     self.weight = weight
     self.completeInput = complete
Ejemplo n.º 7
0
def updateSlider(val):
    if isNone(val):
        return nu
    return []
Ejemplo n.º 8
0
def renderMPSettings(outcolumn):
    if isNone(outcolumn):
        return [0, 0, {}, []]
    exists, data = existsData()
    mv = data.getOutlierBlockLengths(outcolumn) if exists else 0
    return [0, mv, {i: str(i) for i in range(mv)}, []]