Esempio n. 1
0
 def call_cusum(self, other_args: List[str]):
     """Process cusum command"""
     parser = argparse.ArgumentParser(
         add_help=False,
         formatter_class=argparse.ArgumentDefaultsHelpFormatter,
         prog="cusum",
         description="""
             Cumulative sum algorithm (CUSUM) to detect abrupt changes in data
         """,
     )
     parser.add_argument(
         "-t",
         "--threshold",
         dest="threshold",
         type=float,
         default=(max(self.data.values) - min(self.data.values)) / 40,
         help="threshold",
     )
     parser.add_argument(
         "-d",
         "--drift",
         dest="drift",
         type=float,
         default=(max(self.data.values) - min(self.data.values)) / 80,
         help="drift",
     )
     ns_parser = parse_known_args_and_warn(parser, other_args)
     if ns_parser:
         qa_view.display_cusum(
             df=self.current_source_dataframe,
             target=self.current_id,
             threshold=ns_parser.threshold,
             drift=ns_parser.drift,
         )
Esempio n. 2
0
    def call_cusum(self, other_args: List[str]):
        """Process cusum command"""
        parser = argparse.ArgumentParser(
            add_help=False,
            formatter_class=argparse.ArgumentDefaultsHelpFormatter,
            prog="cusum",
            description="""
                Cumulative sum algorithm (CUSUM) to detect abrupt changes in data
            """,
        )
        parser.add_argument(
            "-t",
            "--threshold",
            dest="threshold",
            type=float,
            default=(
                max(self.stock[self.target].values)
                - min(self.stock[self.target].values)
            )
            / 40,
            help="threshold",
        )
        parser.add_argument(
            "-d",
            "--drift",
            dest="drift",
            type=float,
            default=(
                max(self.stock[self.target].values)
                - min(self.stock[self.target].values)
            )
            / 80,
            help="drift",
        )

        try:
            ns_parser = parse_known_args_and_warn(parser, other_args)
            if not ns_parser:
                return

            qa_view.display_cusum(
                df=self.stock,
                target=self.target,
                threshold=ns_parser.threshold,
                drift=ns_parser.drift,
            )
        except Exception as e:
            print(e, "\n")