吴裕雄 python深度学习与实践(5)

import numpy as np

data = np.mat([[1,200,105,3,False],
               [2,165,80,2,False],
               [3,184.5,120,2,False],
               [4,116,70.8,1,False],
               [5,270,150,4,True]])
row = 0
for line in data:
    row += 1
print(row)
print(data.size)

import numpy as np

data = np.mat([[1,200,105,3,False],
               [2,165,80,2,False],
               [3,184.5,120,2,False],
               [4,116,70.8,1,False],
               [5,270,150,4,True]])
print(data[0,3])
print(data[0,4])

import numpy as np

data = np.mat([[1,200,105,3,False],
               [2,165,80,2,False],
               [3,184.5,120,2,False],
               [4,116,70.8,1,False],
               [5,270,150,4,True]])
print(data)
col1 = []
for row in data:
    print(row)
    col1.append(row[0,1])

print(col1)
print(np.sum(col1))
print(np.mean(col1))
print(np.std(col1))
print(np.var(col1))

import pylab
import numpy as np
import scipy.stats as stats

data = np.mat([[1,200,105,3,False],
               [2,165,80,2,False],
               [3,184.5,120,2,False],
               [4,116,70.8,1,False],
               [5,270,150,4,True]])

col1 = []
for row in data:
    col1.append(row[0,1])

stats.probplot(col1,plot=pylab)
pylab.show()

import pandas as pd
import matplotlib.pyplot as plot

rocksVMines = pd.DataFrame([[1,200,105,3,False],
                            [2,165,80,2,False],
                            [3,184.5,120,2,False],
                            [4,116,70.8,1,False],
                            [5,270,150,4,True]])
print(rocksVMines)
dataRow1 = rocksVMines.iloc[1,0:3]
dataRow2 = rocksVMines.iloc[2,0:3]
print(type(dataRow1))
print(dataRow1)
print(dataRow2)
plot.scatter(dataRow1, dataRow2)
plot.xlabel("Attribute1")
plot.ylabel("Attribute2")
plot.show()

dataRow3 = rocksVMines.iloc[3,0:3]
plot.scatter(dataRow2, dataRow3)
plot.xlabel("Attribute2")
plot.ylabel("Attribute3")
plot.show()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plot

filePath = ("G:\\MyLearning\\TensorFlow_deep_learn\\data\\dataTest.csv")
dataFile = pd.read_csv(filePath,header=None, prefix="V")
print(np.shape(dataFile))
dataRow1 = dataFile.iloc[100,1:300]
dataRow2 = dataFile.iloc[101,1:300]
plot.scatter(dataRow1, dataRow2)
plot.xlabel("Attribute1")
plot.ylabel("Attribute2")
plot.show()

import pandas as pd
import matplotlib.pyplot as plot

filePath = ("G:\\MyLearning\\TensorFlow_deep_learn\\data\\dataTest.csv")
dataFile = pd.read_csv(filePath,header=None, prefix="V")

target = []
for i in range(200):
    if dataFile.iat[i,10] >= 7:
        target.append(1.0)
    else:
        target.append(0.0)

dataRow = dataFile.iloc[0:200,10]
plot.scatter(dataRow, target)
plot.xlabel("Attribute")
plot.ylabel("Target")
plot.show()

import random as rd
import pandas as pd
import matplotlib.pyplot as plot

filePath = ("G:\\MyLearning\\TensorFlow_deep_learn\\data\\dataTest.csv")
dataFile = pd.read_csv(filePath,header=None, prefix="V")

target = []
for i in range(200):
    if dataFile.iat[i,10] >= 7:
        target.append(1.0 + rd.uniform(-0.3, 0.3))
    else:
        target.append(0.0 + rd.uniform(-0.3, 0.3))
dataRow = dataFile.iloc[0:200,10]
plot.scatter(dataRow, target, alpha=0.5, s=100)
plot.xlabel("Attribute")
plot.ylabel("Target")
plot.show()

from pylab import *
import pandas as pd
import matplotlib.pyplot as plot

filePath = ("G:\\MyLearning\\TensorFlow_deep_learn\\data\\dataTest.csv")
dataFile = pd.read_csv(filePath,header=None, prefix="V")

print(dataFile.head())
print(dataFile.tail())

summary = dataFile.describe()
print(summary)

array = dataFile.iloc[:,10:16].values
boxplot(array)
plot.xlabel("Attribute")
plot.ylabel("Score")
show()

原文地址:https://www.cnblogs.com/tszr/p/10354547.html

时间: 2024-11-06 09:49:29

吴裕雄 python深度学习与实践(5)的相关文章

吴裕雄 python深度学习与实践(1)

#coding = utf8 import threading,time count = 0 class MyThread(threading.Thread): def __init__(self,threadName): super(MyThread,self).__init__(name = threadName) def run(self): global count for i in range(100): count = count + 1 time.sleep(0.3) print(

吴裕雄 python深度学习与实践(2)

#coding = utf8 import threading,time,random count = 0 class MyThread (threading.Thread): def __init__(self,lock,threadName): super(MyThread,self).__init__(name = threadName) self.lock = lock def run(self): global count self.lock.acquire() for i in ra

吴裕雄 python深度学习与实践(3)

import threading, time def doWaiting(): print('start waiting:', time.strftime('%S')) time.sleep(3) print('stop waiting', time.strftime('%S')) thread1 = threading.Thread(target = doWaiting) thread1.start() time.sleep(1) #确保线程thread1已经启动 print('start j

吴裕雄 python深度学习与实践(4)

import numpy,math def softmax(inMatrix): m,n = numpy.shape(inMatrix) outMatrix = numpy.mat(numpy.zeros((m,n))) soft_sum = 0 for idx in range(0,n): outMatrix[0,idx] = math.exp(inMatrix[0,idx]) soft_sum += outMatrix[0,idx] for idx in range(0,n): outMat

吴裕雄 python深度学习与实践(6)

from pylab import * import pandas as pd import matplotlib.pyplot as plot import numpy as np filePath = ("G:\\MyLearning\\TensorFlow_deep_learn\\data\\dataTest.csv") dataFile = pd.read_csv(filePath,header=None, prefix="V") summary = dat

吴裕雄 python深度学习与实践(7)

import cv2 import numpy as np img = np.mat(np.zeros((300,300))) cv2.imshow("test",img) cv2.waitKey(0) import cv2 import numpy as np img = np.mat(np.zeros((300,300),dtype=np.uint8)) cv2.imshow("test",img) cv2.waitKey(0) import cv2 impor

吴裕雄 python深度学习与实践(8)

import cv2 import numpy as np img = cv2.imread("G:\\MyLearning\\TensorFlow_deep_learn\\data\\lena.jpg") img_hsv = cv2.cvtColor(img,cv2.COLOR_BGR2HSV) turn_green_hsv = img_hsv.copy() turn_green_hsv[:,:,0] = (turn_green_hsv[:,:,0] - 30 ) % 180 tur

吴裕雄 python深度学习与实践(10)

import tensorflow as tf input1 = tf.constant(1) print(input1) input2 = tf.Variable(2,tf.int32) print(input2) input2 = input1 sess = tf.Session() print(sess.run(input2)) import tensorflow as tf input1 = tf.placeholder(tf.int32) input2 = tf.placeholder

吴裕雄 python深度学习与实践(11)

import numpy as np from matplotlib import pyplot as plt A = np.array([[5],[4]]) C = np.array([[4],[6]]) B = A.T.dot(C) AA = np.linalg.inv(A.T.dot(A)) l=AA.dot(B) P=A.dot(l) x=np.linspace(-2,2,10) x.shape=(1,10) xx=A.dot(x) fig = plt.figure() ax= fig.