예제 #1
0
    def Builder(error=False,
                cv=False,
                accuracy=False,
                name='./GraphBuilder_default_name.png',
                legend_on=True,
                Xlabel='epochs',
                Ylabel='Error',
                Title='Error vs epochs',
                **kwargs):

        #Colors
        Colors = ['c', 'm', 'y', 'k', colors.cnames['darkseagreen'], colors.cnames['darkslateblue'], colors.cnames['darkslategray'],
                  colors.cnames['darkturquoise'], colors.cnames['darkviolet'], colors.cnames['deeppink'],
                  colors.cnames['deepskyblue'], colors.cnames['dimgray']]
        color_idx = 0

        #Add declared dict
        allDicts = dict()
        allDicts['error'] = error
        allDicts['cv'] = cv
        allDicts['accuracy'] = accuracy

        #Add kwargs
        for k in kwargs.keys():
            allDicts[k] = kwargs[k]

        #Define valid dicts
        validDicts = dict()
        for k in allDicts.keys():
            if any(allDicts[k]):
                validDicts[k] = allDicts[k]

        #Define longest (with more points) graph
        lenLongestDict = 0
        keylongestDict = None
        for k in validDicts.keys():
            if len(validDicts[k]) > lenLongestDict:
                lenLongestDict = len(validDicts[k])
                keylongestDict = k

        #Calc axes's step
        stepsDict = dict()
        for k in validDicts.keys():
            numberOfPoints = len(validDicts[k])
            stepsDict[k] = np.round(np.linspace(0, lenLongestDict, numberOfPoints, endpoint=True))

        #plot
        for k in validDicts.keys():
            if k == 'error':
                plot(stepsDict[k], validDicts[k], 'r,', markeredgewidth=0, label='Error', zorder=0)
            elif k == 'cv':
                plot(stepsDict[k], validDicts[k], 'g.', markersize=4, markeredgewidth=0, label='CV', zorder=3)
            elif k == 'accuracy':
                plot(stepsDict[k], validDicts[k], 'b.', markeredgewidth=0, label='Accuracy', zorder=2)
            else:
                plot(stepsDict[k], validDicts[k], Colors[color_idx], marker='.', ls='-', markeredgewidth=0, label=k, zorder=1)
                color_idx += 1

        #Titles
        title(Title, fontsize=12)
        xlabel(Xlabel, fontsize=10)
        ylabel(Ylabel, fontsize=10)
        if legend_on:
            legend(loc='best', fontsize=10, numpoints=3, shadow=True, fancybox=True)

        #Grid
        grid()
        margins(0.04)
        savefig(name, dpi=120, bbox_inches='tight')
        close()
예제 #2
0
    def Builder(error=False,
                cv=False,
                accuracy=False,
                name='./GraphBuilder_default_name.png',
                legend_on=True,
                Xlabel='epochs',
                Ylabel='Error',
                Title='Error vs epochs',
                **kwargs):

        #Colors
        Colors = [
            'c', 'm', 'y', 'k', colors.cnames['darkseagreen'],
            colors.cnames['darkslateblue'], colors.cnames['darkslategray'],
            colors.cnames['darkturquoise'], colors.cnames['darkviolet'],
            colors.cnames['deeppink'], colors.cnames['deepskyblue'],
            colors.cnames['dimgray']
        ]
        color_idx = 0

        #Add declared dict
        allDicts = dict()
        allDicts['error'] = error
        allDicts['cv'] = cv
        allDicts['accuracy'] = accuracy

        #Add kwargs
        for k in kwargs.keys():
            allDicts[k] = kwargs[k]

        #Define valid dicts
        validDicts = dict()
        for k in allDicts.keys():
            if any(allDicts[k]):
                validDicts[k] = allDicts[k]

        #Define longest (with more points) graph
        lenLongestDict = 0
        keylongestDict = None
        for k in validDicts.keys():
            if len(validDicts[k]) > lenLongestDict:
                lenLongestDict = len(validDicts[k])
                keylongestDict = k

        #Calc axes's step
        stepsDict = dict()
        for k in validDicts.keys():
            numberOfPoints = len(validDicts[k])
            stepsDict[k] = np.round(
                np.linspace(0, lenLongestDict, numberOfPoints, endpoint=True))

        #plot
        for k in validDicts.keys():
            if k == 'error':
                plot(stepsDict[k],
                     validDicts[k],
                     'r,',
                     markeredgewidth=0,
                     label='Error',
                     zorder=0)
            elif k == 'cv':
                plot(stepsDict[k],
                     validDicts[k],
                     'g.',
                     markersize=4,
                     markeredgewidth=0,
                     label='CV',
                     zorder=3)
            elif k == 'accuracy':
                plot(stepsDict[k],
                     validDicts[k],
                     'b.',
                     markeredgewidth=0,
                     label='Accuracy',
                     zorder=2)
            else:
                plot(stepsDict[k],
                     validDicts[k],
                     Colors[color_idx],
                     marker='.',
                     ls='-',
                     markeredgewidth=0,
                     label=k,
                     zorder=1)
                color_idx += 1

        #Titles
        title(Title, fontsize=12)
        xlabel(Xlabel, fontsize=10)
        ylabel(Ylabel, fontsize=10)
        if legend_on:
            legend(loc='best',
                   fontsize=10,
                   numpoints=3,
                   shadow=True,
                   fancybox=True)

        #Grid
        grid()
        margins(0.04)
        savefig(name, dpi=120, bbox_inches='tight')
        close()
예제 #3
0
    def Builder(
        error=False, cv=False, accuracy=False, name="./GraphBuilder_default_name.png", legend_on=True, **kwargs
    ):

        # Colors
        Colors = ["c", "m", "y", "k"]
        color_idx = 0

        # Add declared dict
        allDicts = dict()
        allDicts["error"] = error
        allDicts["cv"] = cv
        allDicts["accuracy"] = accuracy

        # Add kwargs
        for k in kwargs.keys():
            allDicts[k] = kwargs[k]

        # Define valid dicts
        validDicts = dict()
        for k in allDicts.keys():
            if any(allDicts[k]):
                validDicts[k] = allDicts[k]

        # Define longest (with more points) graph
        lenLongestDict = 0
        keylongestDict = None
        for k in validDicts.keys():
            if len(validDicts[k]) > lenLongestDict:
                lenLongestDict = len(validDicts[k])
                keylongestDict = k

        # Calc axes's step
        stepsDict = dict()
        for k in validDicts.keys():
            numberOfPoints = len(validDicts[k])
            stepsDict[k] = np.round(np.linspace(0, lenLongestDict, numberOfPoints, endpoint=True))

        # plot
        for k in validDicts.keys():
            if k == "error":
                plot(stepsDict[k], validDicts[k], "r,", markeredgewidth=0, label="Error", zorder=0)
            elif k == "cv":
                plot(stepsDict[k], validDicts[k], "g.", markeredgewidth=0, label="CV", zorder=3)
            elif k == "accuracy":
                plot(stepsDict[k], validDicts[k], "b.", markeredgewidth=0, label="Accuracy", zorder=2)
            else:
                plot(stepsDict[k], validDicts[k], str(Colors[color_idx] + "."), markeredgewidth=0, label=k, zorder=1)
                color_idx += 1

        # Titles
        title("Error vs epochs", fontsize=12)
        xlabel("epochs", fontsize=10)
        ylabel("Error", fontsize=10)
        if legend_on:
            legend(loc="upper right", fontsize=10, numpoints=3, shadow=True, fancybox=True)

        # Grid
        grid()
        margins(0.04)
        savefig(name, dpi=120)
        close()
예제 #4
0
    def Builder(error=False,
                cv=False,
                accuracy=False,
                name='./GraphBuilder_default_name.png',
                legend_on=True,
                **kwargs):

        #Colors
        Colors = ['c', 'm', 'y', 'k']
        color_idx = 0

        #Add declared dict
        allDicts = dict()
        allDicts['error'] = error
        allDicts['cv'] = cv
        allDicts['accuracy'] = accuracy

        #Add kwargs
        for k in kwargs.keys():
            allDicts[k] = kwargs[k]

        #Define valid dicts
        validDicts = dict()
        for k in allDicts.keys():
            if any(allDicts[k]):
                validDicts[k] = allDicts[k]

        #Define longest (with more points) graph
        lenLongestDict = 0
        keylongestDict = None
        for k in validDicts.keys():
            if len(validDicts[k]) > lenLongestDict:
                lenLongestDict = len(validDicts[k])
                keylongestDict = k

        #Calc axes's step
        stepsDict = dict()
        for k in validDicts.keys():
            numberOfPoints = len(validDicts[k])
            stepsDict[k] = np.round(
                np.linspace(0, lenLongestDict, numberOfPoints, endpoint=True))

        #plot
        for k in validDicts.keys():
            if k == 'error':
                plot(stepsDict[k],
                     validDicts[k],
                     'r,',
                     markeredgewidth=0,
                     label='Error',
                     zorder=0)
            elif k == 'cv':
                plot(stepsDict[k],
                     validDicts[k],
                     'g.',
                     markeredgewidth=0,
                     label='CV',
                     zorder=3)
            elif k == 'accuracy':
                plot(stepsDict[k],
                     validDicts[k],
                     'b.',
                     markeredgewidth=0,
                     label='Accuracy',
                     zorder=2)
            else:
                plot(stepsDict[k],
                     validDicts[k],
                     str(Colors[color_idx] + '.'),
                     markeredgewidth=0,
                     label=k,
                     zorder=1)
                color_idx += 1

        #Titles
        title('Error vs epochs', fontsize=12)
        xlabel('epochs', fontsize=10)
        ylabel('Error', fontsize=10)
        if legend_on:
            legend(loc='upper right',
                   fontsize=10,
                   numpoints=3,
                   shadow=True,
                   fancybox=True)

        #Grid
        grid()
        margins(0.04)
        savefig(name, dpi=120)
        close()