コード例 #1
0
def plotStats(fileName):
    # read in a playlist
    plist = plistlib.readPlist(fileName)
    # get tracks from playlist
    tracks = plist['Tracks']
    # create lists of song ratings and track durations
    ratings = []
    durations = []
    # iterate through the tracks
    for trackId, track in tracks.items():
        try:
            ratings.append(track['Album Rating'])
            durations.append(track['Total Time'])
        except:
            #ignore
            pass
    # ensure valid data was collected
    if ratings == [] or durations == []:
        print("No valid Album Rating/Total Time data in %s." % fileName)
        return

    # scatter plot
    x = np.array(durations, np.int32)
    # convert to minutes
    x = x/60000.0
    y = np.array(ratings, np.int32)
    pyplot.subplot(2, 1, 1)
    pyplot(x, y, 'o')
    pyplot.axis([0, 1.05*np.max(x), -1, 110])
    pyplot.xlabel('Track duration')
    pyplot.ylabel('Track rating')

    # plot histogram
    pyplot.subplot(2, 1, 2)
    pyplot.hist(x, bins=20)
    pyplot.xlabel('Track duration')
    pyplot.ylabel('Count')

    # show plot
    pyplot.show()
コード例 #2
0
def main():
    points=get_point_data('./scene0000_00_vh_clean_2.labels.ply')
    points=points[:]
    print(points)
    vols=oint_cloud_to_volume(points,4096,radius=1.0)
    pyplot(vol)
コード例 #3
0
    for point in pointslist[i]:
        p = Point(point[0], point[1])
        if p.within(boundary) or checkPointOnBoundary(p):
            w[i].point(p.x, p.y)
            w[i].field('%d_FLD' % c)
        c += 1
        """
		if len(w[i].shapes())>=2:
			w[i].save(writePath)
		"""

print("Number of shapes = %d \n\n" % len(w))
n = 0
for shape in w:
    print("shape %d contains %d points" % (n + 1, len(w[i].shapes())))
    n += 1

for wr in w:
    for s in wr.shapes():
        x = []
        y = []
        for p in s.points:
            print(p)
            x.append(p.x)
            y.append(p.y)
        pyplot(x, y)

pyplot.xlim(-5, 5)
pyplot.ylim(-5, 5)
pyplot.show()
		p = Point(point[0],point[1])
		if p.within(boundary) or checkPointOnBoundary(p):
			w[i].point(p.x,p.y)
			w[i].field('%d_FLD' % c)
		c +=1
		"""
		if len(w[i].shapes())>=2:
			w[i].save(writePath)
		"""

print("Number of shapes = %d \n\n" % len(w))
n = 0
for shape in w: 
	print("shape %d contains %d points" %(n+1, len(w[i].shapes())))
	n += 1

for wr in w:
	for s in wr.shapes():
		x=[];y=[]
		for p in s.points:
			print(p)
			x.append(p.x)
			y.append(p.y)
		pyplot(x,y)


pyplot.xlim(-5, 5)
pyplot.ylim(-5, 5)
pyplot.show()

コード例 #5
0
ファイル: 37.py プロジェクト: slaveveve/NLP100
# 37. 頻度上位10語
# 出現頻度が高い10語とその出現頻度をグラフ(例えば棒グラフなど)で表示せよ.

import matplotlib as plt
frequency = __import__('36').frequency

frequency = sorted(frequency.items(), key=lambda x:x[1], reverse=True)
frequency[:10]

plt.pyplot()
コード例 #6
0
K = kahan_matrix(n, theta)

print('Computed svd rank of matrix B:', compute_rank_svd(B, thres))
print('Computed qr rank of matrix B:', compute_rank_qr(B, thres))
print('Computed lu rank of matrix B:', compute_rank_lu(B, thres))
print('Computed python rank matric B:', np.linalg.matrix_rank(B))

print('Computed svd rank of matrix A:', compute_rank_svd(A, thres))
print('Computed qr rank of matrix A:', compute_rank_qr(A, thres))
print('Computed lu rank of matrix A:', compute_rank_lu(A, thres))
print('Computed python rank matric A:', np.linalg.matrix_rank(A))

print('Computed svd rank of matrix C:', compute_rank_svd(C, thres))
print('Computed qr rank of matrix C:', compute_rank_qr(C, thres))
print('Computed lu rank of matrix C:', compute_rank_lu(C, thres))
print('Computed python rank matric C:', np.linalg.matrix_rank(C))

print('Computed svd rank of matrix D:', compute_rank_svd(D, thres))
print('Computed qr rank of matrix D:', compute_rank_qr(D, thres))
print('Computed lu rank of matrix D:', compute_rank_lu(D, thres))
print('Computed python rank matric D:', np.linalg.matrix_rank(D))

print('Computed svd rank of matrix K:', compute_rank_svd(K, thres))
print('Computed qr rank of matrix K:', compute_rank_qr(K, thres))
print('Computed lu rank of matrix K:', compute_rank_lu(K, thres))
print('Computed python rank matric K:', np.linalg.matrix_rank(K))

#%% kladd

matplotlib.pyplot(pyplot.imshow(K))
コード例 #7
0
ファイル: drl_test1.py プロジェクト: ncaldwell17/chicago
            d = False
            j = 0
            #The Q-Network
            while j < 99:
                j+=1
                #Choose an action by greedily (with e chance of random action) from the Q-network
                a,allQ = sess.run([predict,Qout],feed_dict={inputs1:np.identity(16)[s:s+1]})
                if np.random.rand(1) < e:
                    a[0] = env.action_space.sample()
                #Get new state and reward from environment
                s1,r,d,_ = env.step(a[0])
                #Obtain the Q' values by feeding the new state through our network
                Q1 = sess.run(Qout,feed_dict={inputs1:np.identity(16)[s1:s1+1]})
                #Obtain maxQ' and set our target value for chosen action.
                maxQ1 = np.max(Q1)
                targetQ = allQ
                targetQ[0,a[0]] = r + y*maxQ1
                #Train our network using target and predicted Q values
                _,W1 = sess.run([updateModel,W],feed_dict={inputs1:np.identity(16)[s:s+1],nextQ:targetQ})
                rAll += r
                s = s1
                if d == True:
                    #Reduce chance of random action as we train the model.
                    e = 1./((i/50) + 10)
                    break
            jList.append(j)
            rList.append(rAll)
    print("Percent of succesful episodes: " + str(sum(rList)/num_episodes) + "%")

    plt.pyplot(rList)
コード例 #8
0
# Uses alpha from mask
student_img.paste(earth_small, (1162, 966), mask=earth_small)
# Display
fig3, axes3 = plt.subplots(1, 2)
axes3[0].imshow(student_img, interpolation='none')
axes3[1].imshow(student_img, interpolation='none')
axes3[1].set_xlim(500, 1500)
axes3[1].set_ylim(1130, 850)
fig3.savefig('earth_eye')

print(earth_img.size)
print(earth_small.size)
print(earth_img.size[1])

#13.
"""
matplotlib.pyplot (plt) The matplotlib library helps to plot images on a coordinate plane.

numpy (np) Creates an array set for the images.

PIL  manipulates the images by cropping, filtering, etc
"""

#15.
'''
a.
Line 19 calls the function subplots from the matplotlib library. The function is being
called with 2 argument(s): 1,2. The function returns 2 object(s), which is/are being assigned to ax.

b.
Line 20 calls __imshow()_ on ___ax[0]____