Ejemplo n.º 1
0
 def similarPattern(self, query, topK=-1):
     from lux.service.patternSearch.similarityDistance import euclideanDist
     from lux.compiler.Compiler import applyDataTransformations
     result = lux.Result()
     rowSpecs = list(filter(lambda x: x.className == "Row", query.spec))
     if (len(rowSpecs) == 1):
         query.dataset = applyDataTransformations(query.dataset,
                                                  rowSpecs[0].fAttribute,
                                                  rowSpecs[0].fVal)
         query.preprocess()
         #for loop to create assign euclidean distance
         recommendation = {
             "action":
             "Similarity",
             "description":
             "Show other charts that are visually similar to the Current View."
         }
         for dobj in self.compiled.collection:
             dobj.preprocess()
             dobj.score = euclideanDist(query, dobj)
         self.compiled.normalizeScore(invertOrder=True)
         self.compiled.sort(removeInvalid=True)
         if (topK != -1):
             self.compiled = self.compiled.topK(topK)
         recommendation["collection"] = self.compiled
         result.addResult(recommendation, dobj)
         return result
     else:
         print("Query needs to have 1 row value")
Ejemplo n.º 2
0
    def show_more(self):
        from lux.action.UserDefined import user_defined
        from lux.action.Correlation import correlation
        from lux.action.Univariate import univariate
        from lux.action.Enhance import enhance
        from lux.action.Filter import filter
        from lux.action.Generalize import generalize

        self._rec_info = []
        no_view = len(self.current_view) == 0
        one_current_view = len(self.current_view) == 1
        multiple_current_views = len(self.current_view) > 1

        if (no_view):
            self._rec_info.append(correlation(self))
            self._rec_info.append(univariate(self, "quantitative"))
            self._rec_info.append(univariate(self, "nominal"))
            self._rec_info.append(univariate(self, "temporal"))
        elif (one_current_view):
            enhance = enhance(self)
            filter = filter(self)
            generalize = generalize(self)
            if enhance['collection']:
                self._rec_info.append(enhance)
            if filter['collection']:
                self._rec_info.append(filter)
            if generalize['collection']:
                self._rec_info.append(generalize)
        elif (multiple_current_views):
            self._rec_info.append(user_defined(self))

        # Store _rec_info into a more user-friendly dictionary form
        self.recommendation = {}
        for rec_info in self._rec_info:
            action_type = rec_info["action"]
            vc = rec_info["collection"]
            if (self.plot_config):
                for view in vc:
                    view.plot_config = self.plot_config
            if (len(vc) > 0):
                self.recommendation[action_type] = vc

        self.clear_filter()
Ejemplo n.º 3
0
    def showMore(self):
        from lux.action.UserDefined import userDefined
        from lux.action.Correlation import correlation
        from lux.action.Distribution import distribution
        from lux.action.Enhance import enhance
        from lux.action.Filter import filter
        from lux.action.Generalize import generalize

        self._recInfo = []
        noView = len(self.viewCollection) == 0
        oneCurrentView = len(self.viewCollection) == 1
        multipleCurrentViews = len(self.viewCollection) > 1

        if (noView):
            self._recInfo.append(correlation(self))
            self._recInfo.append(distribution(self, "quantitative"))
            self._recInfo.append(distribution(self, "nominal"))
        elif (oneCurrentView):
            enhance = enhance(self)
            filter = filter(self)
            generalize = generalize(self)
            if enhance['collection']:
                self._recInfo.append(enhance)
            if filter['collection']:
                self._recInfo.append(filter)
            if generalize['collection']:
                self._recInfo.append(generalize)
        elif (multipleCurrentViews):
            self._recInfo.append(userDefined(self))

        # Store _recInfo into a more user-friendly dictionary form
        self.recommendation = {}
        for recInfo in self._recInfo:
            actionType = recInfo["action"]
            vc = recInfo["collection"]
            if (self.plotConfig):
                for view in vc:
                    view.plotConfig = self.plotConfig
            self.recommendation[actionType] = vc

        self.clearFilter()
Ejemplo n.º 4
0
 def mapping(self, rmap):
     groupMap = {}
     for val in ["quantitative", "ordinal", "nominal", "temporal"]:
         groupMap[val] = list(filter(lambda x: rmap[x] == val, rmap))
     return groupMap
Ejemplo n.º 5
0
 def getObjFromChannel(self, channel):
     specObj = list(
         filter(
             lambda x: x.channel == channel
             if hasattr(x, "channel") else False, self.spec))
     return specObj
Ejemplo n.º 6
0
 def getObjByRowColType(self, rowColType):
     specObj = list(filter(lambda x: x.className == rowColType, self.spec))
     return specObj
Ejemplo n.º 7
0
 def filter(self):
     from lux.action.Filter import filter
     return filter(self)
Ejemplo n.º 8
0
 def removeColumnFromSpec(self, columnName):
     self.spec = list(
         filter(lambda x: x.columnName != columnName, self.spec))
Ejemplo n.º 9
0
 def getByColumnName(self, columnName):
     return list(filter(lambda x: x.columnName == columnName, self.spec))
Ejemplo n.º 10
0
 def getObjByDataModel(self, dmodel):
     return list(
         filter(
             lambda x: x.dataModel == dmodel
             if hasattr(x, "dataModel") else False, self.spec))