Ejemplo n.º 1
0
    def show_MLP_options(self):
        """
        Callback to open MLP parameters options
        :return: suitable parameters for MLP algorithm
        """

        self.parent.show_algorithms_options(load_anomaly_detection_list()[2])
Ejemplo n.º 2
0
    def show_Random_Forest_options(self):
        """
        Callback to open Random forest parameters options
        :return: suitable parameters for Random forest algorithm
        """

        self.parent.show_algorithms_options(load_anomaly_detection_list()[3])
Ejemplo n.º 3
0
    def show_LSTM_options(self):
        """
        Callback to open LSTM parameters options
        :return: suitable parameters for LSTM algorithm
        """

        self.parent.show_algorithms_options(load_anomaly_detection_list()[0])
Ejemplo n.º 4
0
    def show_SVR_options(self):
        """
        Callback to open SVR parameters options
        :return: suitable parameters for SVR algorithm
        """

        self.parent.show_algorithms_options(load_anomaly_detection_list()[1])
Ejemplo n.º 5
0
    def __init__(self, parent, controller):
        """
        Parameters
        ----------

        :param parent: window
        :param controller: GUI controller
        """

        tk.Frame.__init__(self, parent)

        # Page init
        self.controller = controller
        self.menubar = Menubar(controller)
        # Disables ability to tear menu bar into own window
        self.controller.option_add('*tearOff', 'FALSE')
        system_logo = CROSS_WINDOWS_SETTINGS.get('LOGO')
        photo_location = os.path.join(system_logo)
        global logo_img
        logo_img = tk.PhotoImage(file=photo_location)

        # Page header
        self.logo_png = tk.Button(self)
        self.logo_png.place(relx=0.28, rely=0.029, height=172, width=300)
        set_logo_configuration(self.logo_png, image=logo_img)

        self.instructions = tk.Label(self)
        self.instructions.place(relx=0.015, rely=0.3, height=32, width=635)
        self.instructions.configure(
            text=
            '''Please select the algorithms for which you want to build anomaly detection models.'''
        )
        set_widget_to_left(self.instructions)

        # Page body
        self.anomaly_detection_methods = Checkbar(
            self,
            picks=load_anomaly_detection_list(),
            editButtons=True,
            checkCallback=self.set_algorithm_checked)
        self.anomaly_detection_methods.place(relx=0.1,
                                             rely=0.35,
                                             height=400,
                                             width=700)

        # Page footer
        self.next_button = HoverButton(self, command=self.next_window)
        self.next_button.place(relx=0.813, rely=0.839, height=25, width=81)
        set_button_configuration(self.next_button, text='''Next''')

        self.back_button = HoverButton(
            self, command=lambda: controller.show_frame("NewModel"))
        self.back_button.place(relx=0.017, rely=0.839, height=25, width=81)
        set_button_configuration(self.back_button, text='''Back''')

        self.copyright = tk.Label(self)
        self.copyright.place(relx=0, rely=0.958, height=25, width=750)
        set_copyright_configuration(self.copyright)
Ejemplo n.º 6
0
    def get_algorithm_set_function(algorithm_name):
        algorithms = load_anomaly_detection_list()

        # Switch to get the suitable set function for a given algorithm
        switcher = {
            algorithms[0]: InputSettings.set_LSTM,
            algorithms[1]: InputSettings.set_SVR,
            algorithms[2]: InputSettings.set_MLP,
            algorithms[3]: InputSettings.set_Random_Forest
        }

        return switcher.get(algorithm_name, None)
Ejemplo n.º 7
0
    def get_algorithm_show_function(self, algorithm_name):
        """
        Switch to get the callback according to a given algorithm name
        :param algorithm_name: input algorithm
        :return: callback suitable for input algorithm name
        """

        algorithms = load_anomaly_detection_list()

        # Switch between algorithms' callbacks
        switcher = {
            algorithms[0]: self.show_LSTM_options,
            algorithms[1]: self.show_SVR_options,
            algorithms[2]: self.show_MLP_options,
            algorithms[3]: self.show_Random_Forest_options
        }

        return switcher.get(algorithm_name, None)
    def get_algorithm_execution_function(algorithm_name):
        """
        switch to get the execution function for a given algorithm
        :param algorithm_name:
        :return: execution function suitable to input algorithm
        """

        algorithms = load_anomaly_detection_list()

        # Switch to get the suitable execute function for a given algorithm
        switcher = {
            algorithms[0]: ModelsExecution.LSTM_execution,
            algorithms[1]: ModelsExecution.SVR_execution,
            algorithms[2]: ModelsExecution.MLP_execution,
            algorithms[3]: ModelsExecution.Random_Forest_execution
        }

        return switcher.get(algorithm_name, None)
Ejemplo n.º 9
0
    def __init__(self, parent, controller):
        """
        Parameters
        ----------

        :param parent: window
        :param controller: GUI controller
        """

        tk.Frame.__init__(self, parent)

        # Page init
        self.controller = controller
        self.menubar = Menubar(controller)
        # Disables ability to tear menu bar into own window
        self.controller.option_add('*tearOff', 'FALSE')
        system_logo = CROSS_WINDOWS_SETTINGS.get('LOGO')
        photo_location = os.path.join(system_logo)
        global logo_img
        logo_img = tk.PhotoImage(file=photo_location)

        # Page header
        self.logo_png = tk.Button(self)
        self.logo_png.place(relx=0.28, rely=0.029, height=172, width=300)
        set_logo_configuration(self.logo_png, image=logo_img)

        self.instructions = tk.Label(self)
        self.instructions.place(relx=0.015, rely=0.3, height=32, width=635)
        self.instructions.configure(
            text=
            '''Please select the values for each of the following parameters:'''
        )
        set_widget_to_left(self.instructions)

        # Page body

        # Dynamic algorithm options
        self.algorithms_files = load_anomaly_detection_list()
        self.current_algorithm = self.controller.get_current_algorithm_to_edit(
        )
        self.current_yaml = self.set_suitable_yaml_file(self.current_algorithm)

        self.height_options_frame = 268
        self.width_options_frame = 620

        self.options_to_show = AlgorithmFrameOptions(
            self, yaml_filename=self.current_yaml)
        self.options_to_show.place(relx=0.05,
                                   rely=0.35,
                                   height=self.height_options_frame,
                                   width=self.width_options_frame)

        # Page footer
        self.next_button = HoverButton(self, command=self.handle_next_button)
        self.next_button.place(relx=0.813, rely=0.839, height=25, width=81)
        set_button_configuration(self.next_button, text='''Save''')

        self.back_button = HoverButton(
            self,
            command=lambda: self.controller.show_frame("AlgorithmsWindow"))
        self.back_button.place(relx=0.017, rely=0.839, height=25, width=81)
        set_button_configuration(self.back_button, text='''Cancel''')

        self.copyright = tk.Label(self)
        self.copyright.place(relx=0, rely=0.958, height=25, width=750)
        set_copyright_configuration(self.copyright)
    def reinitialize(self):
        """
        Reinitialize frame values and view
        :return: new frame view
        """

        self.features_columns_options = {}
        self.features_columns_options = self.get_features_columns_options()

        self.csv_features = tk.StringVar()
        self.csv_features.set(self.features_columns_options)

        self.input_indicator = False
        self.target_indicator = False
        self.windows_indicator = False

        self.select_all_features_button = tk.Button(
            self, command=self.select_all_features)
        self.select_all_features_button.place(relx=0.17,
                                              rely=0.38,
                                              height=18,
                                              width=55)
        set_button_configuration(self.select_all_features_button,
                                 text='''Select all''')
        self.select_all_features_button.configure(bg='sandy brown')

        self.features_listbox = tk.Listbox(
            self,
            font=tkfont.Font(size=9),
            listvariable=self.csv_features,
            selectmode=tk.MULTIPLE,
            exportselection=
            0,  # Fix : ComboBox clears unrelated ListBox selection
            width=120,
            height=180,
            bd=3,
            bg='antique white',
            selectbackground='sandy brown')
        self.features_listbox.place(relx=0.05,
                                    rely=0.42,
                                    height=230,
                                    width=140)

        self.select_all_target_button = tk.Button(
            self, bg='sky blue', command=self.select_all_target)
        self.select_all_target_button.place(relx=0.42,
                                            rely=0.38,
                                            height=18,
                                            width=55)
        set_button_configuration(self.select_all_target_button,
                                 text='''Select all''')
        self.select_all_target_button.configure(bg='sandy brown')

        self.target_features_listbox = tk.Listbox(
            self,
            font=tkfont.Font(size=9),
            listvariable=self.csv_features,
            selectmode=tk.MULTIPLE,
            exportselection=0,
            # Fix : ComboBox clears unrelated ListBox selection
            width=120,
            height=180,
            bd=3,
            bg='antique white',
            selectbackground='sandy brown')
        self.target_features_listbox.place(relx=0.3,
                                           rely=0.42,
                                           height=230,
                                           width=140)

        window_options = tk.StringVar()
        numbers = list(range(1, 16))
        window_options.set([str(i) for i in numbers])

        self.select_all_windows_button = tk.Button(
            self, bg='sky blue', command=self.select_all_windows)
        self.select_all_windows_button.place(relx=0.67,
                                             rely=0.38,
                                             height=18,
                                             width=55)
        set_button_configuration(self.select_all_windows_button,
                                 text='''Select all''')
        self.select_all_windows_button.configure(bg='sandy brown')

        self.window_size_listbox = tk.Listbox(
            self,
            font=tkfont.Font(size=9),
            listvariable=window_options,
            selectmode=tk.MULTIPLE,
            exportselection=0,
            # Fix : ComboBox clears unrelated ListBox selection
            width=120,
            height=180,
            bd=3,
            bg='antique white',
            selectbackground='sandy brown')
        self.window_size_listbox.place(relx=0.55,
                                       rely=0.42,
                                       height=230,
                                       width=140)

        algorithms_list = load_anomaly_detection_list()

        self.algorithm_combo = ttk.Combobox(self,
                                            state="readonly",
                                            values=algorithms_list)
        self.algorithm_combo.place(relx=0.78, rely=0.47, height=25, width=130)
        self.algorithm_combo.current(0)