@@ -405,7 +405,7 @@ solutions within the population.
405405 population_matrices = gacnn.population_as_matrices(population_networks = GACNN_instance .population_networks, population_vectors = ga_instance.population)
406406 GACNN_instance .update_population_trained_weights(population_trained_weights = population_matrices)
407407
408- print (" Generation = {generation} " .format( generation = ga_instance.generations_completed) )
408+ print (f " Generation = { ga_instance.generations_completed} " )
409409
410410 After preparing the fitness and callback function, next is to create an
411411instance of the ``pygad.GA `` class.
@@ -462,7 +462,7 @@ be called to show how the fitness values evolve by generation.
462462
463463 ga_instance.plot_fitness()
464464
465- .. figure :: https://user-images.githubusercontent.com/16560492/83429675-ab744580-a434-11ea-8f21-9d3804b50d15.png
465+ .. image :: https://user-images.githubusercontent.com/16560492/83429675-ab744580-a434-11ea-8f21-9d3804b50d15.png
466466 :alt:
467467
468468Information about the Best Solution
@@ -483,9 +483,9 @@ Here is how such information is returned.
483483.. code :: python
484484
485485 solution, solution_fitness, solution_idx = ga_instance.best_solution()
486- print (" Parameters of the best solution : {solution} " .format( solution = solution) )
487- print (" Fitness value of the best solution = {solution_fitness} " .format( solution_fitness = solution_fitness) )
488- print (" Index of the best solution : {solution_idx} " .format( solution_idx = solution_idx) )
486+ print (f " Parameters of the best solution : { solution} " )
487+ print (f " Fitness value of the best solution = { solution_fitness} " )
488+ print (f " Index of the best solution : { solution_idx} " )
489489
490490 .. code ::
491491
@@ -504,7 +504,7 @@ the labels correctly.
504504.. code :: python
505505
506506 predictions = pygad.cnn.predict(last_layer = GANN_instance .population_networks[solution_idx], data_inputs = data_inputs)
507- print (" Predictions of the trained network : {predictions} " .format( predictions = predictions) )
507+ print (f " Predictions of the trained network : { predictions} " )
508508
509509 Calculating Some Statistics
510510---------------------------
@@ -518,9 +518,9 @@ addition to the classification accuracy.
518518 num_wrong = numpy.where(predictions != data_outputs)[0 ]
519519 num_correct = data_outputs.size - num_wrong.size
520520 accuracy = 100 * (num_correct/ data_outputs.size)
521- print (" Number of correct classifications : {num_correct} ." .format( num_correct = num_correct) )
522- print (" Number of wrong classifications : {num_wrong} ." .format( num_wrong = num_wrong.size) )
523- print (" Classification accuracy : {accuracy} ." .format( accuracy = accuracy) )
521+ print (f " Number of correct classifications : { num_correct} . " )
522+ print (f " Number of wrong classifications : { num_wrong.size } . " )
523+ print (f " Classification accuracy : { accuracy} . " )
524524
525525 .. code ::
526526
@@ -575,8 +575,8 @@ complete code is listed below.
575575
576576 GACNN_instance .update_population_trained_weights(population_trained_weights = population_matrices)
577577
578- print (" Generation = {generation} " .format( generation = ga_instance.generations_completed) )
579- print (" Fitness = {fitness} " .format( fitness = ga_instance.best_solutions_fitness) )
578+ print (f " Generation = { ga_instance.generations_completed} " )
579+ print (f " Fitness = { ga_instance.best_solutions_fitness} " )
580580
581581 data_inputs = numpy.load(" dataset_inputs.npy" )
582582 data_outputs = numpy.load(" dataset_outputs.npy" )
@@ -642,21 +642,21 @@ complete code is listed below.
642642
643643 # Returning the details of the best solution.
644644 solution, solution_fitness, solution_idx = ga_instance.best_solution()
645- print (" Parameters of the best solution : {solution} " .format( solution = solution) )
646- print (" Fitness value of the best solution = {solution_fitness} " .format( solution_fitness = solution_fitness) )
647- print (" Index of the best solution : {solution_idx} " .format( solution_idx = solution_idx) )
645+ print (f " Parameters of the best solution : { solution} " )
646+ print (f " Fitness value of the best solution = { solution_fitness} " )
647+ print (f " Index of the best solution : { solution_idx} " )
648648
649649 if ga_instance.best_solution_generation != - 1 :
650- print (" Best fitness value reached after {best_solution_generation} generations." .format( best_solution_generation = ga_instance.best_solution_generation) )
650+ print (f " Best fitness value reached after { ga_instance. best_solution_generation} generations. " )
651651
652652 # Predicting the outputs of the data using the best solution.
653653 predictions = GACNN_instance .population_networks[solution_idx].predict(data_inputs = data_inputs)
654- print (" Predictions of the trained network : {predictions} " .format( predictions = predictions) )
654+ print (f " Predictions of the trained network : { predictions} " )
655655
656656 # Calculating some statistics
657657 num_wrong = numpy.where(predictions != data_outputs)[0 ]
658658 num_correct = data_outputs.size - num_wrong.size
659659 accuracy = 100 * (num_correct/ data_outputs.size)
660- print (" Number of correct classifications : {num_correct} ." .format( num_correct = num_correct) )
661- print (" Number of wrong classifications : {num_wrong} ." .format( num_wrong = num_wrong.size) )
662- print (" Classification accuracy : {accuracy} ." .format( accuracy = accuracy) )
660+ print (f " Number of correct classifications : { num_correct} . " )
661+ print (f " Number of wrong classifications : { num_wrong.size } . " )
662+ print (f " Classification accuracy : { accuracy} . " )
0 commit comments