Esempio n. 1
0
    def on_post(self, req, resp):

        req_vars = validate(self.api_def, 'post', req)

        target_row = req_vars['target-row']
        context_column = req_vars['context-column']

        quoted_ctx_column = '"{}"'.format(context_column)

        with self.bdb.savepoint():
            query = self.queries.find_peer_rows(
                population=self.cfg.population_name,
                context_column=quoted_ctx_column,
                target_row=target_row)

            cursor = self.execute(query)
            cols = ['row-id', 'similarity']
            result = [dict(zip(cols, row)) for row in cursor]

            history.save(
                self.cfg.history, {
                    'type': 'peers',
                    'query': query,
                    'result': result,
                    'target_row': target_row,
                    'context_columns': [context_column]
                })

            history.save(self.cfg.history, {'result': result}, "similarity")

        resp.media = result
        resp.status = falcon.HTTP_200
Esempio n. 2
0
    def on_post(self, req, resp):

        req_vars = validate(self.api_def, 'post', req)

        target_column = req_vars['target-column']
        context_columns = req_vars['context-columns']

        quoted_tgt_column = '"{}"'.format(target_column)
        quoted_ctx_columns = ['"{}"'.format(c) for c in context_columns]

        with self.bdb.savepoint():
            query = self.queries.find_anomalies(
                population=self.cfg.population_name,
                target_column=quoted_tgt_column,
                context_columns=quoted_ctx_columns)

            self.logger.info(query)

            cursor = self.execute(query)
            cols = ['row-id', 'probability']
            result = [dict(zip(cols, row)) for row in cursor]

            history.save(
                self.cfg.history, {
                    'type': 'anomalies',
                    'query': query,
                    'result': result,
                    'target_column': target_column,
                    'context_columns': context_columns
                })

            history.save(self.cfg.history, {'result': result}, "anomaly")

        resp.media = result
        resp.status = falcon.HTTP_200
Esempio n. 3
0
    def on_post(self, req, resp):
        table_name = self.cfg.table_name

        req_vars = validate(self.api_def, 'post', req)
        target_column = req_vars['column']

        def normalize(column):
            return column.lower()

        with self.bdb.savepoint():

            def column_names():
                query = self.queries.get_full_table(table_name=table_name)
                cursor = self.execute(query)
                return [tuple[0] for tuple in cursor.description]

            case_mapping = {
                normalize(column): column
                for column in column_names()
            }

        with self.bdb.savepoint():
            create_depprob_table_query = self.queries.create_dependence_probability_table(
                population=self.cfg.population_name)

            self.execute(create_depprob_table_query)

            query = self.queries.select_dependence_probabilities(
                column_name=normalize(target_column))
            result = self.execute(query)

            maps = [{
                'column': case_mapping[row[0]],
                'score': row[1]
            } for row in result.fetchall()
                    if case_mapping[row[0]] != target_column]

        maps.insert(0, {'column': target_column, 'score': 1.0})

        history.save(
            self.cfg.history, {
                'type': 'associated_columns',
                'query': query,
                'target_column': normalize(target_column),
                'result': maps
            })

        resp.media = maps
        resp.status = 200
Esempio n. 4
0
 def closeEvent(self, QCloseEvent):
     history.save()
Esempio n. 5
0
def Rem_fin(text, Title):
    MyUI.label.setText(Title + "\n\n" + text)
    MyUI.Update_List(sched.get_jobs())
    history.save(Title)
Esempio n. 6
0
def save_history(name):
    profile = profiles.current_profile
    history.save(profile, name)