class Experiment: def __init__(self): self.data_loader = DataLoader('/data') self.trainer = Trainer() def run(self): train_data, train_labels = self.data_loader.load_set('train') test_data, test_labels = self.data_loader.load_set('test') train_data = self.data_loader.clean_data(train_data) test_data = self.data_loader.clean_data(test_data) self.trainer.train(train_data, train_labels) train_predictions = self.trainer.predict(train_data) test_predictions = self.trainer.predict(test_data) print('Train accuracy: ', self.compute_score(train_labels, train_predictions)) print('Test accuracy: ', self.compute_score(test_labels, test_predictions)) def compute_score(self, labels, predictions): return metrics.accuracy_score(labels, predictions)
method and compares them ''' #%% # Read the data: data = DataLoader(dataset_name='trade_selection', extension='csv') split = int(data.df.shape[0] * 0.8) # Compute a threshold to create the label: threshold_ = analysis_threshold(data.df, split) # Some plots of the variable Result: plot_result(data.df) plot_hist(data.df) # Clean the data: datas = data.clean_data(threshold=threshold_) old_df = datas.copy() datas = datas.drop(['Result'], axis=1) # Split the train_test and evaluation set: train_evaluation_set = datas.iloc[:split, :] test_set = datas.iloc[split:, :] # Get the block variables: list_var = data.get_list_var_block() #%% OCA method oca_method = OCAMethod(train_evaluation_set, n_min=10, verbose=True, reload_feature_importance=False,
@author: david.saltiel """ from data_loader import DataLoader from OCA import OCAMethod from RFE import RFEMethod from BCA import BCAMethod from graphics import create_graphic_for_method, create_figure2, create_figure3 ''' This is the main function It calls all the 3 features selection method and compares them ''' #%% reads the data data = DataLoader(dataset_name = 'trade_selection_A229', extension = 'csv') data.clean_data() #%% OCA method oca_method = OCAMethod(data.df, n_min=10, verbose = True,reload_feature_importance = False) oca_method.select_features() #%% RFE method rfe_method = RFEMethod(data.df, verbose = True) rfe_method.select_features() rfe_dictionary = rfe_method.save_all_score() #%% BCA method bca_method = BCAMethod(data.df, verbose = True) bca_method.select_features()