def trained_decision_tree(max_depth, x, y): # Create decision tree # print("Called trained_decision_tree") # debug dcsn_tree = DecisionTree(max_depth=max_depth) x_sample, y_sample = Utils.bootstrap_samples(x, y) # bootstrapping samples dcsn_tree.train_decision_tree(x_sample, y_sample) return dcsn_tree
def train_classifiers(self, svm_param_dict=None, rf_param_dict=None, mlp_param_dict=None, adab_param_dict=None): self.__x_train, self.__x_test, self.__y_train, self.__y_test = prepare_data_for_training(Training_Data_Dir) save_mdl = True # ******************************************************************************Setting Up SVM for training x_temp, y_temp = Utils.bootstrap_samples(self.__x_train, self.__y_train) # bootstrap samples if svm_param_dict is not None: self.svm.train_support_vector_machine(x_temp, self.__x_test, y_temp, self.__y_test, save_mdl=save_mdl, **svm_param_dict) else: self.svm.train_support_vector_machine(x_temp, self.__x_test, y_temp, self.__y_test) # ******************************************************************************Setting Up RF for training x_temp, y_temp = Utils.bootstrap_samples(self.__x_train, self.__y_train) # bootstrap samples if rf_param_dict is not None: self.random_forest.train_random_forest(x_temp, self.__x_test, y_temp, self.__y_test, save_mdl=save_mdl, **rf_param_dict) else: self.random_forest.train_random_forest(x_temp, self.__x_test, y_temp, self.__y_test, save_mdl=save_mdl) # ******************************************************************************Setting Up MLP for training x_temp, y_temp = Utils.bootstrap_samples(self.__x_train, self.__y_train) if mlp_param_dict is not None: self.multi_layer_perceptron.train_MultiLayerPerceptron(x_temp, self.__x_test, y_temp, self.__y_test, save_mdl=save_mdl, **mlp_param_dict) else: self.multi_layer_perceptron.train_MultiLayerPerceptron(x_temp, self.__x_test, y_temp, self.__y_test, save_mdl=save_mdl) # ******************************************************************************Setting Up Adaboost for training x_temp, y_temp = Utils.bootstrap_samples(self.__x_train, self.__y_train) if adab_param_dict is not None: self.adaboost.train_adaboost(x_temp, self.__x_test, y_temp, self.__y_test, save_classifiers=save_mdl, **adab_param_dict) else: self.adaboost.train_adaboost(x_temp, self.__x_test, y_temp, self.__y_test, save_classifiers=save_mdl) # self.__models_loaded = True # self.test_main_classifier() return 0