def test_transform(self): read_data = ReadData() loaded_data = read_data.read_data_and_set_variable_settings("../Dataset/00-91-Drugs-All-In-One-File.csv", "../Dataset/VariableSetting.csv") data_manager = DataManager(normalizer=None) data_manager.set_data(loaded_data) data_manager.split_data_into_train_valid_test_sets() model = svm.SVR() velocity = Velocity() velocity_matrix = velocity.create_first_velocity() # define the first population # validation of a row generating random row for population = Population(velocity_matrix=velocity_matrix) population.create_first_population() debpso = DEBPSO(population.population_matrix[0]) debpso.fit(data_manager.inputs[SplitTypes.Train], data_manager.targets[SplitTypes.Train]) data_manager.transformed_input[SplitTypes.Train] = debpso.transform(data_manager.inputs[SplitTypes.Train]) print("Population 0 row sum ", population.population_matrix[0].sum()) print("Selected feature descriptors",debpso.sel_descriptors_for_curr_population) print("Transformed array", data_manager.transformed_input[SplitTypes.Train])
def test_run_experiment_for_DEBPSO_population_With_Velocity(self): read_data = ReadData() loaded_data = read_data.read_data_and_set_variable_settings( "../Dataset/00-91-Drugs-All-In-One-File.csv", "../Dataset/VariableSetting.csv") #output_filename = FileManager.create_output_file() #rescaling_normalizer = RescalingNormalizer() #scikit_normalizer = ScikitNormalizer() #data_manager = DataManager(normalizer=scikit_normalizer) data_manager = DataManager(normalizer=None) data_manager.set_data(loaded_data) data_manager.split_data_into_train_valid_test_sets() #data_manager.feature_selector = debpso feature_selection_algo = None model = None if VariableSetting.Feature_Selection_Algorithm == 'GA' and VariableSetting.Model == 'SVM': #feature_selection_algo = GA() model = svm.SVR() elif VariableSetting.Feature_Selection_Algorithm == 'DEBPSO' and VariableSetting.Model == 'SVM': feature_selection_algo = DEBPSO() model = svm.SVR() experiment = Experiment(data_manager, model, feature_selection_algo) experiment.run_experiment()
def test_verify_variable_assignment(self): read_data = ReadData() loaded_data = read_data.read_data_and_set_variable_settings( "../Dataset/00-91-Drugs-All-In-One-File.csv", "../Dataset/VariableSetting.csv") print("Population ", VariableSetting.Population_Size) print("Descriptor_Selection_Probability ", VariableSetting.Descriptor_Selection_Probability) print("Unfit ", VariableSetting.Unfit) print("Required_r2_Train ", VariableSetting.Required_r2_Train) print("Required_r2_Valid ", VariableSetting.Required_r2_Valid) print("Required_r2_Test ", VariableSetting.Required_r2_Test) print("Generation ", VariableSetting.Generation) print("Stop_time ", VariableSetting.Stop_time) print("Initial_alpha ", VariableSetting.Initial_alpha) print("Ending_alpha ", VariableSetting.Ending_alpha) print("Beta ", VariableSetting.Beta) print("Gamma ", VariableSetting.Gamma) print("Scaling_Factor ", VariableSetting.Scaling_Factor) print("Crossover_Rate ", VariableSetting.Crossover_Rate) print("No_of_Drugs ", VariableSetting.No_of_Drugs) print("No_of_Descriptors ", VariableSetting.No_of_Descriptors) print("Feature_Selection_Algorithm ", VariableSetting.Feature_Selection_Algorithm) print("Model ", VariableSetting.Model)
def test_fit(self): #file_path = "../Dataset/00-91-Drugs-All-In-One-File.csv" #loaded_data = FileManager.load_file(file_path) read_data = ReadData() loaded_data = read_data.read_data_and_set_variable_settings("../Dataset/00-91-Drugs-All-In-One-File.csv", "../Dataset/VariableSetting.csv") data_manager = DataManager(normalizer=None) data_manager.set_data(loaded_data) data_manager.split_data_into_train_valid_test_sets() model = svm.SVR() velocity = Velocity() velocity_matrix = velocity.create_first_velocity() # define the first population # validation of a row generating random row for population = Population(velocity_matrix=velocity_matrix) population.create_first_population() debpso = DEBPSO(population.population_matrix[1]) debpso.fit(data_manager.inputs[SplitTypes.Train], data_manager.targets[SplitTypes.Train])
def test_transform(self): read_data = ReadData() loaded_data = read_data.read_data_and_set_variable_settings( "../Dataset/00-91-Drugs-All-In-One-File.csv", "../Dataset/VariableSetting.csv") data_manager = DataManager(normalizer=None) data_manager.set_data(loaded_data) data_manager.split_data_into_train_valid_test_sets() model = svm.SVR() velocity = Velocity() velocity_matrix = velocity.create_first_velocity() # define the first population # validation of a row generating random row for population = Population(velocity_matrix=velocity_matrix) population.create_first_population() debpso = DEBPSO(population.population_matrix[0]) debpso.fit(data_manager.inputs[SplitTypes.Train], data_manager.targets[SplitTypes.Train]) data_manager.transformed_input[SplitTypes.Train] = debpso.transform( data_manager.inputs[SplitTypes.Train]) print("Population 0 row sum ", population.population_matrix[0].sum()) print("Selected feature descriptors", debpso.sel_descriptors_for_curr_population) print("Transformed array", data_manager.transformed_input[SplitTypes.Train])
def test_fit(self): #file_path = "../Dataset/00-91-Drugs-All-In-One-File.csv" #loaded_data = FileManager.load_file(file_path) read_data = ReadData() loaded_data = read_data.read_data_and_set_variable_settings( "../Dataset/00-91-Drugs-All-In-One-File.csv", "../Dataset/VariableSetting.csv") data_manager = DataManager(normalizer=None) data_manager.set_data(loaded_data) data_manager.split_data_into_train_valid_test_sets() model = svm.SVR() velocity = Velocity() velocity_matrix = velocity.create_first_velocity() # define the first population # validation of a row generating random row for population = Population(velocity_matrix=velocity_matrix) population.create_first_population() debpso = DEBPSO(population.population_matrix[1]) debpso.fit(data_manager.inputs[SplitTypes.Train], data_manager.targets[SplitTypes.Train])
def test_run_experiment_for_DEBPSO_population_With_Velocity(self): read_data = ReadData() loaded_data = read_data.read_data_and_set_variable_settings("../Dataset/00-91-Drugs-All-In-One-File.csv", "../Dataset/VariableSetting.csv") #output_filename = FileManager.create_output_file() #rescaling_normalizer = RescalingNormalizer() #scikit_normalizer = ScikitNormalizer() #data_manager = DataManager(normalizer=scikit_normalizer) data_manager = DataManager(normalizer=None) data_manager.set_data(loaded_data) data_manager.split_data_into_train_valid_test_sets() #data_manager.feature_selector = debpso feature_selection_algo = None model = None if VariableSetting.Feature_Selection_Algorithm == 'GA' and VariableSetting.Model == 'SVM': #feature_selection_algo = GA() model = svm.SVR() elif VariableSetting.Feature_Selection_Algorithm == 'DEBPSO' and VariableSetting.Model == 'SVM': feature_selection_algo = DEBPSO() model = svm.SVR() experiment = Experiment(data_manager, model, feature_selection_algo) experiment.run_experiment()
def test_run_experiment_for_DEBPSO_population_With_Velocity(self): read_data = ReadData() loaded_data = read_data.read_data_and_set_variable_settings("../Dataset/00-91-Drugs-All-In-One-File.csv", "../Dataset/VariableSetting.csv") #output_filename = FileManager.create_output_file() zero_one_normalizer = ZeroOneMinMaxNormalizer() data_manager = DataManager(normalizer=zero_one_normalizer) data_manager.set_data(loaded_data) data_manager.split_data_into_train_valid_test_sets() print("Train Data", data_manager.inputs)
def test_run_experiment_for_DEBPSO_population_With_Velocity(self): read_data = ReadData() loaded_data = read_data.read_data_and_set_variable_settings( "../Dataset/00-91-Drugs-All-In-One-File.csv", "../Dataset/VariableSetting.csv") #output_filename = FileManager.create_output_file() zero_one_normalizer = ZeroOneMinMaxNormalizer() data_manager = DataManager(normalizer=zero_one_normalizer) data_manager.set_data(loaded_data) data_manager.split_data_into_train_valid_test_sets() print("Train Data", data_manager.inputs)
def test_verify_variable_assignment(self): read_data = ReadData() loaded_data = read_data.read_data_and_set_variable_settings("../Dataset/00-91-Drugs-All-In-One-File.csv", "../Dataset/VariableSetting.csv") print("Population ", VariableSetting.Population_Size) print("Descriptor_Selection_Probability ", VariableSetting.Descriptor_Selection_Probability) print("Unfit ", VariableSetting.Unfit) print("Required_r2_Train ", VariableSetting.Required_r2_Train) print("Required_r2_Valid ", VariableSetting.Required_r2_Valid) print("Required_r2_Test ", VariableSetting.Required_r2_Test) print("Generation ", VariableSetting.Generation) print("Stop_time ", VariableSetting.Stop_time) print("Initial_alpha ", VariableSetting.Initial_alpha) print("Ending_alpha ", VariableSetting.Ending_alpha) print("Beta ", VariableSetting.Beta) print("Gamma ", VariableSetting.Gamma) print("Scaling_Factor ", VariableSetting.Scaling_Factor) print("Crossover_Rate ", VariableSetting.Crossover_Rate) print("No_of_Drugs ", VariableSetting.No_of_Drugs) print("No_of_Descriptors ", VariableSetting.No_of_Descriptors) print("Feature_Selection_Algorithm ", VariableSetting.Feature_Selection_Algorithm) print("Model ", VariableSetting.Model)
from src.DEBPSO import DEBPSO from src.Experiment import Experiment from src.Normalizer import ZeroOneMinMaxNormalizer from sklearn.preprocessing import MinMaxScaler from src.Population import Population from src.ReadData import ReadData from src.SplitTypes import SplitTypes from src.FileManager import FileManager from src.DataManager import DataManager from src.VariableSetting import VariableSetting from src.Velocity import Velocity read_data = ReadData() loaded_data = read_data.read_data_and_set_variable_settings( "../Dataset/00-91-Drugs-All-In-One-File.csv", "../Dataset/VariableSetting.csv") output_filename = FileManager.create_output_file() #normalizer = ZeroOneMinMaxNormalizer() #normalizer = MinMaxScaler() normalizer = None data_manager = DataManager(normalizer=normalizer) data_manager.set_data(loaded_data) data_manager.split_data_into_train_valid_test_sets() #data_manager.feature_selector = debpso #set feature selection algorithm based on variable settings feature_selection_algo = None if VariableSetting.Feature_Selection_Algorithm == 'DEBPSO':