def CalcFitness(self, network, layers, outputs): client = NetworkClient(self.data) fitness = client.testing(layers, outputs, network) # print("Fitness for this individual is: ") # print(fitness) print("Calculated Fitness ", fitness) return fitness
def test_it_all(self): data = Data('abalone', pd.read_csv(r'data/abalone.data', header=None), 8, False) df = data.df.sample(100) data.split_data(data_frame=df) client = NetworkClient(data) layers, outputset, network = client.train_it(1, 10, .1, .5, 10) print(layers) print(client.testing(layers, outputset, network)) # prints total
def test_it_all(self): data = Data('abalone', pd.read_csv(r'data/abalone.data', header=None), 8, False) df = data.df.sample(n=200) data.split_data(data_frame=df) client = NetworkClient(data) layers, outputset, network = client.train_it(1, 10, .3, .5, 15) # print(client.testing(layers, outputset, network)) # prints total lf = LF() pred, actual = client.testing(layers, outputset, network) print("Predicted Set, ", pred, " Actual Set: ", actual)
def test_de(self): data = Data('abalone', pd.read_csv(r'data/abalone.data', header=None), 8, False) df = data.df.sample(100) data.split_data(data_frame=df) de_algo = DE(50, .7, 2, 4, data, max_runs=100, mutation_rate=.03) bestC = de_algo.run_DE() print("Best fitting vector") print(bestC.net_vector) client = NetworkClient(data) network = NeuralNetwork(data) new_Net = network.GADEnet(bestC.layers, bestC.net_vector) print("Printing testing results") print(client.testing(new_Net, bestC.outputs, bestC.network))
def run_pop_algos_for_vid(): "run the pop algos for proj4 vid" # setup data to use data = Data('abalone', pd.read_csv(r'data/abalone.data', header=None), 8, False) # take a sample as results do not matter for this df = data.df.sample(100) data.split_data(data_frame=df) gen_algo = GA(1000, 4, data, max_runs=1000, mutation_rate=1) print("----------------------- RUNNING THE GA -----------------") # get chromosome object from GA bestC = gen_algo.run_GA() print("Best fitting vector From the GA") print(bestC.net_vector) client = NetworkClient(data) network = NeuralNetwork(data) new_Net = network.GADEnet(bestC.layers, bestC.net_vector) print("Printing testing results from the GA") print(client.testing(new_Net, bestC.outputs, bestC.network)) print("----------------------- GA DONE -----------------") print("---------------------------------------------------") print("---------------------------------------------------") print("---------------------------------------------------") print("----------------------- RUNNING DE -----------------") de_algo = DE(10, .7, 2, 4, data, max_runs=100, mutation_rate=.03) bestC = de_algo.run_DE() print("Best fitting vector from DE") print(bestC.net_vector) client = NetworkClient(data) network = NeuralNetwork(data) new_Net = network.GADEnet(bestC.layers, bestC.net_vector) print("Printing testing results from DE") print(client.testing(new_Net, bestC.outputs, bestC.network)) print("----------------------- DE DONE -----------------")