Exemple #1
0
    def __init__(self, dispatcher_config: DispatcherConfig):
        """

        :param dispatcher_config:
        :raise
        """
        super().__init__()

        print(f"version: {__version__.__version__}")

        # Validate python version
        Validation.python_version(FileObserver.PY_VERSION_MIN, f"Python version required >= {FileObserver.PY_VERSION_MIN}")

        self.__dispatcher_config = dispatcher_config

        # Load loggers
        self.__init_loggers(dispatcher_config.log_filename)
        # Validate rules
        self.__validate_rules()
        # Check permissions
        self.__check_permissions()

        self.__dir_obs_dict = self.__fill_dict(dispatcher_config.dispatcher_sources)
        self.__event_handler = FileEventHandler(
            RuleBuilder.build_list(
                dispatcher_config.dispatcher_rules,
                dispatcher_config.dispatcher_formats,
                dispatcher_config.dispatcher_sources,
                dispatcher_config.dispatcher_destinations
            ),
            dispatcher_config.general_threads
        )
    def __init__(self, conf: Conf):
        super().__init__()

        # validate python version
        Validation.python_version(
            Evaluator.REQUIRED_PYTHON, f"Unsupported Python version.\n"
            f"Required Python {Evaluator.REQUIRED_PYTHON[0]}.{Evaluator.REQUIRED_PYTHON[1]} or higher."
        )
        Validation.can_read(
            conf.dataset_train,
            f"Training set file *must* exists and be readable. "
            f"Current file: '{conf.dataset_train}'.\n"
            f"Training set path (fully qualified) can be specified in conf.ini file or using Conf object."
        )
        Validation.can_read(
            conf.dataset_test, f"Test set file *must* exists and be readable. "
            f"Current file: '{conf.dataset_test}'.\n"
            f"Test set path (fully qualified) can be specified in conf.ini file or using Conf object."
        )

        self.__LOG = LogManager.get_instance().logger(LogManager.Logger.EVAL)
        self.__conf = conf

        # using full dataset as training set
        self.__training = Set(pd.read_csv(self.conf.dataset_train))

        # load test set if it has same format as training_set.csv provided
        # as example file see ./res/dataset/test_set_no_index.csv
        self.__test = Set(pd.read_csv(self.conf.dataset_test))
        # load test set if it has header (F1-20 and CLASS row) and index, so a test test saved using
        #   command pd.to_csv('/path', index=True)
        # as example file see ./res/dataset/test_set_index.csv
        # self.__test = Set(pd.read_csv(self.conf.dataset_test, index_col=0))
        # load test set if it does not have header row (does not have F1-20 and CLASS row) and
        #   it is was not saved using command pd.to_csv('/path', index=True), so it has not index
        # as example file see ./res/dataset/test_set_no_index_features.csv
        # self.__test = Set(pd.read_csv(self.conf.dataset_test, header=None,
        #                               names=[f"F{i}" for i in range(1, 21)] + ["CLASS"]))

        # current classifiers used
        self.__classifiers = {
            Evaluator._MULTILAYER_PERCEPTRON:
            None,
            Evaluator._SUPPORT_VECTOR_MACHINE:
            None,
            # Evaluator._DECISION_TREE: None,
            Evaluator._RANDOM_FOREST:
            None,
            # Evaluator._KNEAREST_NEIGHBORS: None,
            # Evaluator._STOCHASTIC_GRADIENT_DESCENT: None,
            Evaluator._ADA_BOOST:
            None,
            # Evaluator._NAIVE_BAYES: None,
            # Evaluator._KMEANS: None
        }