From 04370fb98cd683fde157e2cf565485c1d51de878 Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Sun, 17 May 2020 11:22:38 +0200 Subject: [PATCH] Added docstrings --- src/AI/resultsExplorer/resultsExplorer.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/AI/resultsExplorer/resultsExplorer.py b/src/AI/resultsExplorer/resultsExplorer.py index 5fe5c94..83c1ec5 100644 --- a/src/AI/resultsExplorer/resultsExplorer.py +++ b/src/AI/resultsExplorer/resultsExplorer.py @@ -3,6 +3,7 @@ A small script to help you analyze the output logs from GA algorithm. It shows you best and worst population with all values. Specify the input file as an exec parameter. """ + import sys from ast import literal_eval import matplotlib.pyplot as plt @@ -10,6 +11,11 @@ import numpy def fitnessPlot(pop): + """ + Draw a fitness plot and write it to a file + + :param pop: Population array with fitness + """ fig, ax = plt.subplots() ax.plot([i[4] for i in pop]) ax.set_title("Best fitness by generation") @@ -22,6 +28,11 @@ def fitnessPlot(pop): def printBestWorstGenes(pop): + """ + Print info about best and worst specimen. + + :param pop: Population array with fitness + """ fitnesses = [i[4] for i in pop] bestIdxs = (numpy.where(fitnesses == numpy.max(fitnesses)))[0]