Exemplo n.º 1
0
def draw(xy_matrix, info='<None>'):
    """Draw an XY matrix and attach some info"""
    from matplotlib import pyplot
    pyplot.copper()
    pyplot.matshow(xy_matrix)
    pyplot.xlabel(info, color="red")
    pyplot.show()
Exemplo n.º 2
0
def not_used04():
    values = np.random.rand(10, 10)
    print(values)
    print(values.shape)

    plt.imshow(values)  # image show
    plt.copper()  # colormap 변경, default viridis
    plt.show()
def main():
    global switchBool
    global x
    z = 0
    a = 0
    c = 0
    d = 0
    e = 0

    plt.axis([0, 100, 0, 50])
    i = 0
    # for i in range(50):
    while i < 1000:
        i = i + 1
        events = get_key()
        if events:
            x = int(events[0].state)
            switchBool = not switchBool
            if switchBool:
                d = x

                if x == 72:
                    a = 1
                elif x == 80:
                    a = -1
                elif x == 77:
                    a = 0

                z = z + a

                plt.plot(i / 10, z, 'ro')

                plt.plot(c / 10, e, 'bo')
                print(i / 10, z, "heyo")
                print(c / 10, e, "oyeh")

                c = i
                e = z

                print(i / 10, z, "      heyo")
                print(c / 10, e, "      oyeh")

                plt.pause(0.001)
                print(i)
                plt.copper()

                plt.autoscale(enable=True, axis='both', tight=False)
    #plt.autoscale(enable=True, axis='y', tight=False)
    plt.show()
Exemplo n.º 4
0
def renderGraphs(data):
    font = {'size': 10, 'color': 'blue'}

    if not os.path.exists('./grafer'):
        os.mkdir('./grafer')

    for case in data.keys():
        mpl.copper()
        for algorithm in data[case].keys():
            mpl.plot(list(data[case][algorithm].keys()),
                     list(data[case][algorithm].values()))
        mpl.legend(data[case].keys())
        mpl.grid(True)
        mpl.title('Skaleringstest - {}'.format(case))
        mpl.tick_params(axis='x', labelrotation=45, labelsize=6)
        mpl.xlabel('Elementer i listen')
        mpl.ylabel('Tid')
        mpl.savefig('./grafer/{}.png'.format(case), dpi=300)
        mpl.clf()
Exemplo n.º 5
0
def main():
    global switchBool
    global x
    z =0
    a = 0
    c = 0
    d = 0

    plt.axis([0, 100, 0, 50])
    i = 0
    # for i in range(50):
    while i < 1000:
        i = i + 1
        events = get_key()
        if events:
            x = int(events[0].state)
            switchBool = not switchBool
            if switchBool:
                d = x


                if x == 72:
                    a = 1
                elif x == 80:
                    a = -1

                y = m.sin(i/10)
                z = d
                b = (c + a)*y
                c = b
                print("x  ",x)
                print("b"  ,b)
                plt.scatter(i/2, b)
                plt.pause(0.001)
                print(i)
                plt.copper()
                plt.autoscale(enable=True, axis='both', tight=False)
    plt.show()
Exemplo n.º 6
0
    def do_plot(
        self,
        axs,
        axs_labels=None,
        color='r',
        marker='.',
        lw=1,
        label="Label"
    ):  # FIXME what is len(axs) is > 3 ? Use Multidim Scaling or Feature selection
        if axs_labels is None:
            axs_labels = ["Axis " + str(i + 1) for i in range(len(axs))]

        if len(axs) == 1:
            axs = [range(len(axs[0]))] + axs
            axs_labels = ["Samples"] + axs_labels
        elif len(axs) > 3:
            axs = list(zip(*self.PCA_Transform(axs)))

        if self.plots is None:
            self.start_plot(axs_labels)

        if all([isinstance(v, datetime.date) for v in axs[0]]):
            self.plots.set_xlim([min(axs[0]), max(axs[0])])
            plt.gcf().autofmt_xdate()
            self.plots.xaxis.set_major_locator(MinuteLocator(interval=15))
            self.plots.xaxis.set_major_formatter(
                DateFormatter("%Y-%m-%d %H:%M"))

        if marker == '-':
            self.plots.plot(*axs, c=color, lw=lw, label=label)
        else:
            self.plots.scatter(*axs,
                               c=color,
                               marker=marker,
                               lw=self.lw,
                               s=self.s,
                               cmap=plt.copper(),
                               label=label)

        self.plots.legend(loc='best', ncol=2)
Exemplo n.º 7
0
import time
overall_start = time.time()

import nengo
import build


import numpy as np
import matplotlib.pyplot as plt
plt.copper()
import argparse
from mytools import hrr, nf, fh, nengo_plot_helper, extract_probe_data
import random

from matplotlib import rc, font_manager
plt.rc('text', usetex=True)
plt.rc('axes', color_cycle=['gray'])

seed = 510
random.seed(seed)

sim_class = nengo.Simulator
learning_time = 2 #in seconds
testing_time = 0.1 #in seconds
ttms = testing_time * 1000 #in ms
hrr_num = 1

DperE = 64
dim = 64
num_ensembles = int(dim / DperE)
dim = num_ensembles * DperE
Exemplo n.º 8
0
	def do_plot(self, axs, axs_labels = None, color = 'r', marker = '.'): # FIXME what is len(axs) is > 3 ? Use Multidim Scaling or Feature selection
		if axs_labels is None:
			axs_labels = [ "Axis "+str(i+1) for i in range( len(axs) ) ]
		
		if len(axs) == 1:
			axs = [ range( len(axs[0]) ) ] + axs
			axs_labels = [ "Samples" ] + axs_labels
		
		if self.plots is None:
			self.start_plot( axs_labels )
		
		if marker == '-': self.plots.plot( *axs, c = color, lw = 1 )
		else: self.plots.scatter( *axs, c = color, marker = marker, lw = self.lw, s = self.s, cmap = plt.copper() )
		
		# Re adjusting the xrange, yrange and zrange limits FIXME
		'''
Exemplo n.º 9
0
	def query_disagreement_test(self):
		ids, _ = self.query_margin()
		scores = []
		plots_Y = []; plots_X0 = []; plots_X1 = []; plots_X2 = []; plots_X3 = []; plots_X4 = []; plots_X5 = []; plots_X6 = []; viz = Visualize()
		
		commitee = []
		for idp, dp in enumerate(self.Ux):
			if idp in ids[:self.optimize]:
				true_y = self.Uy[idp]
				# true_y = self.clf.predict_label(dp)
				
				temp_clf = Classification(self.Lx + [dp], self.Ly + [true_y], method = self.clf.method)
				temp_clf.GAMMA, temp_clf.C = self.clf.GAMMA, self.clf.C; temp_clf.train()
				commitee.append( (temp_clf, 1) )
				
		# ===========================
		# sampled = random.sample(ids, 100)
		
		for ix, x in enumerate(self.Ux):
			# if ix in sampled:
			if ix in ids[:self.optimize*9999999]:
				informativeness1 = self.get_disag1(x, weighted = False)
				informativeness2 = self.get_disag2(x, commitee, weighted = False)
				informativeness3 = self.get_disag1(x, weighted = True)
				informativeness4 = self.get_disag2(x, commitee, weighted = True)
				informativeness5 = self.clf.uncertainty_prediction(x)
				informativeness6 = self.get_balance(x)
				
				temp_clf = Classification(self.Lx + [x], self.Ly + [self.Uy[ix]], method = self.clf.method)
				temp_clf.GAMMA, temp_clf.C = self.clf.GAMMA, self.clf.C; temp_clf.train()
				acc = temp_clf.getTestAccuracy( self.Tx, self.Ty )
				
				plots_X0.append( acc )
				plots_X1.append( informativeness1 )
				plots_X2.append( informativeness2 )
				plots_X3.append( informativeness3 )
				plots_X4.append( informativeness4 )
				plots_X5.append( informativeness5 )
				plots_X6.append( informativeness6 )
				plots_Y.append( 'r' if self.Uy[ix] != self.clf.predict_label(x) else 'b' )
				
				fig, axs = plt.subplots( 1, 1, sharex=True )
				axs.scatter( plots_X1, plots_X2, c = plots_Y, marker = "o", cmap = plt.copper() )
				plt.savefig(str(len(self.Lx)) + self.datasetname+'.1-2.png'); plt.close()
				
				fig, axs = plt.subplots( 1, 1, sharex=True )
				axs.scatter( plots_X3, plots_X4, c = plots_Y, marker = "o", cmap = plt.copper() )
				plt.savefig(str(len(self.Lx)) + self.datasetname+'.3-4.png'); plt.close()
				
				fig, axs = plt.subplots( 1, 1, sharex=True )
				axs.scatter( plots_X1, plots_X0, c = plots_Y, marker = "o", cmap = plt.copper() )
				plt.savefig(str(len(self.Lx)) + self.datasetname+'.1-acc.png'); plt.close()
				
				fig, axs = plt.subplots( 1, 1, sharex=True )
				axs.scatter( plots_X2, plots_X0, c = plots_Y, marker = "o", cmap = plt.copper() )
				plt.savefig(str(len(self.Lx)) + self.datasetname+'.2-acc.png'); plt.close()
				
				fig, axs = plt.subplots( 1, 1, sharex=True )
				axs.scatter( plots_X3, plots_X0, c = plots_Y, marker = "o", cmap = plt.copper() )
				plt.savefig(str(len(self.Lx)) + self.datasetname+'.3-acc.png'); plt.close()
				
				fig, axs = plt.subplots( 1, 1, sharex=True )
				axs.scatter( plots_X4, plots_X0, c = plots_Y, marker = "o", cmap = plt.copper() )
				plt.savefig(str(len(self.Lx)) + self.datasetname+'.4-acc.png'); plt.close()
				
				fig, axs = plt.subplots( 1, 1, sharex=True )
				axs.scatter( plots_X5, plots_X0, c = plots_Y, marker = "o", cmap = plt.copper() )
				plt.savefig(str(len(self.Lx)) + self.datasetname+'.5-acc.png'); plt.close()
				
				fig, axs = plt.subplots( 1, 1, sharex=True )
				axs.scatter( plots_X6, plots_X0, c = plots_Y, marker = "o", cmap = plt.copper() )
				plt.savefig(str(len(self.Lx)) + self.datasetname+'.6-acc.png'); plt.close()
				
				# plots = [ plots_X1, plots_X2, plots_X3, plots_X4, plots_X5, plots_X6 ]
				# fig, axs = plt.subplots( 5, 1, sharex=True )
				# axs[0].scatter( Util.normalize(plots_X1), plots_X0, c = plots_Y, marker = "o", cmap = plt.copper() )
				# axs[1].scatter( Util.normalize(plots_X2), plots_X0, c = plots_Y, marker = "o", cmap = plt.copper() )
				# axs[2].scatter( Util.normalize(plots_X3), plots_X0, c = plots_Y, marker = "o", cmap = plt.copper() )
				# axs[3].scatter( Util.normalize(plots_X4), plots_X0, c = plots_Y, marker = "o", cmap = plt.copper() )
				# axs[4].scatter( Util.normalize(plots_X5), plots_X0, c = plots_Y, marker = "o", cmap = plt.copper() )
				# axs[5].scatter( Util.normalize(plots_X6), plots_X0, c = plots_Y, marker = "o", cmap = plt.copper() )
				# plt.savefig(str(len(self.Lx)) + self.datasetname+'.png')
				# plt.close()

				informativeness = acc
			else: informativeness = 0.
			
			scores.append( informativeness )
		
		return self.sort_scores(scores)
Exemplo n.º 10
0
	def do_plot(self, axs, axs_labels = None, color = 'r', marker = '.', lw = 1, label="Label"): # FIXME what is len(axs) is > 3 ? Use Multidim Scaling or Feature selection
		if axs_labels is None:
			axs_labels = [ "Axis "+str(i+1) for i in range( len(axs) ) ]
		
		if len(axs) == 1:
			axs = [ range( len(axs[0]) ) ] + axs
			axs_labels = [ "Samples" ] + axs_labels
		elif len(axs) > 3:
			axs = list(zip(*self.PCA_Transform(axs)))
		
		if self.plots is None:
			self.start_plot( axs_labels )
		
		if all([ isinstance(v, datetime.date) for v in axs[0] ]):
			self.plots.set_xlim([ min(axs[0]), max(axs[0]) ]) 
			plt.gcf().autofmt_xdate()
			self.plots.xaxis.set_major_locator(MinuteLocator(interval=15))
			self.plots.xaxis.set_major_formatter( DateFormatter("%Y-%m-%d %H:%M") )
			
		if marker == '-':
			self.plots.plot( *axs, c = color, lw = lw, label=label )
		else:
			self.plots.scatter( *axs, c = color, marker = marker, lw = self.lw, s = self.s, cmap = plt.copper(), label=label )
			
		self.plots.legend(loc='best', ncol=2)