コード例 #1
0
ファイル: my.py プロジェクト: 888/Assignments
def main():
	for count in range(5):
		output1 = []
		output1.append(testCarData()[1])
		print "accuracy1", testCarData()[1]
		print "max", max(output1)
		print "stddev", stDeviation(output1)
		print "average", average(output1)

		output2 = []
		output2.append(testPenData()[1])
		print "accuracy2", testPenData()[1]
		print "max", max(output2)
		print "stddev", stDeviation(output2)
		print "average", average(output2)
コード例 #2
0
ファイル: q6_testcar.py プロジェクト: gitdarrion/neural-net
def varyPtronsTestCarData():
    ptrons = 0
    testAccuracy = []
    while ptrons <= 40:
        nnet, ta = testCarData([ptrons])
        testAccuracy.append(ta)
        ptrons += 5
    return testAccuracy
コード例 #3
0
def trainCarDataWithRestart(n, hiddenLayerPerceptrons=None):
    accuracyList = []
    with open(OUTPUT_FILENAME, 'a+') as fh:
        fh.write("-------------------- Training with " +
                 str(hiddenLayerPerceptrons) +
                 " Perceptron(s) --------------------\n")
        fh.write("Start training car data for " + str(n) + " round(s) ...\n")
    for run in range(n):
        if hiddenLayerPerceptrons is not None:
            _, accuracy = testCarData(hiddenLayers=[hiddenLayerPerceptrons])
        else:
            _, accuracy = testCarData()
        accuracyList.append(accuracy)
        with open(OUTPUT_FILENAME, 'a+') as fh:
            fh.write("Round " + str(run + 1) + ": " + str(accuracy) + "\n")
    with open(OUTPUT_FILENAME, 'a+') as fh:
        fh.write("All rounds finished.\n")
        fh.write("---------- Accuracy Statistics ----------\n")
        fh.write("Max               : " + str(max(accuracyList)) + "\n")
        fh.write("Average           : " + str(average(accuracyList)) + "\n")
        fh.write("Standard Deviation: " + str(stDeviation(accuracyList)) +
                 "\n\n")
コード例 #4
0
def main():
	count = 0
	while count <= 40:
		output1 = []
		output2 = []
		for num in range(5):
			output1.append(testCarData([count])[1])
			output2.append(testPenData([count])[1])

		print "max1", max(output1)
		print "stddev1", stDeviation(output1)
		print "average1", average(output1)

		print "max2", max(output2)
		print "stddev2", stDeviation(output2)
		print "average2", average(output2)

		count += 5
コード例 #5
0
ファイル: q5.py プロジェクト: pbokey/CS_3600_Intro_AI_GT
from NeuralNetUtil import buildExamplesFromCarData, buildExamplesFromPenData
from NeuralNet import buildNeuralNet
from Testing import testPenData, testCarData, average, stDeviation

accuracyPenData = []
accuracyCarData = []

for i in range(5):
    nnet, accuracy = testPenData()
    accuracyPenData.append(accuracy)
    nnet, accuracyCar = testCarData()
    accuracyCarData.append(accuracyCar)

print("Pen Data Average Accuracy: ", average(accuracyPenData))
print("Pen Data Max Accuracy: ", max(accuracyPenData))
print("Pen Data St Dev Accuracy: ", stDeviation(accuracyPenData))
print(accuracyPenData)

print("Car Data Average Accuracy: ", average(accuracyCarData))
print("Car Data Max Accuracy: ", max(accuracyCarData))
print("Car Data St Dev Accuracy: ", stDeviation(accuracyCarData))
print(accuracyCarData)
コード例 #6
0
from Testing import testPenData, testCarData, average, stDeviation

penList = []
carList = []

for i in range(5):
    penResults = testPenData()
    penList.append(penResults[1])
    carResults = testCarData()
    carList.append(carResults[1])

print 'Pen', penList
print 'Car', carList
penAverage = average(penList)
penStDev = stDeviation(penList)
penMax = max(penList)

carAverage = average(carList)
carStDev = stDeviation(carList)
carMax = max(carList)

print 'Pen:', penAverage, penStDev, penMax
print 'Car:', carAverage, carStDev, carMax

コード例 #7
0
with open('Pen0.csv', 'wb') as csvfile:
    spamwriter = csv.writer(csvfile,
                            delimiter=',',
                            quotechar='|',
                            quoting=csv.QUOTE_MINIMAL)
    spamwriter.writerow([
        'Data Type', 'Perceptrons', 'Average Accuracy', 'Standard Deviation',
        'Maximum Accuracy'
    ])

    for i in range(0, 9):
        penAccuracyList = []
        carAccuracyList = []
        for k in range(5):
            penAccuracyList.append(testPenData(hiddenLayers=[i * 5])[1])
            carAccuracyList.append(testCarData(hiddenLayers=[i * 5])[1])
        avgPen = average(penAccuracyList)
        stDevPen = stDeviation(penAccuracyList)
        maxPen = max(penAccuracyList)

        avgCar = average(carAccuracyList)
        stDevCar = stDeviation(carAccuracyList)
        maxCar = max(carAccuracyList)
        print "writing"
        spamwriter.writerow(
            ['PenData',
             str(i * 5),
             str(avgPen),
             str(stDevPen),
             str(maxPen)])
        spamwriter.writerow(
コード例 #8
0
ファイル: q6.py プロジェクト: jennifer-ma/code
maxRound = round( maximumPen, 3)
maximumPenList.append( maxRound )

avg = round( average( accuracyListPen ) , 3)
avgPenList.append( avg )

stdev = round( stDeviation( accuracyListPen ) , 3)
stdevPenList.append( stdev )


# do hidden layer size = 0, for Car
maximumCar = 0
accuracyListCar = []
for i in xrange(5):
	nnet, accuracy = testCarData( [] )
	# accuracyList.append(accuracy)
	accuracyListCar.append(accuracy)
	if maximumCar < accuracy:
		maximumCar = accuracy

maxRound = round( maximumCar, 3)
maximumCarList.append( maxRound )

avg = round( average( accuracyListCar ) , 3)
avgCarList.append( avg )

stdev = round( stDeviation( accuracyListCar ) , 3)
stdevCarList.append( stdev )

# do hidden layer size = 5, 10, ..., 40
コード例 #9
0
import Testing
from Testing import testCarData
from Testing import testPenData
from Testing import average
from Testing import stDeviation
from NeuralNetUtil import buildExamplesFromCarData, buildExamplesFromPenData
from NeuralNet import buildNeuralNet
import cPickle
from math import pow, sqrt

if __name__ == "__main__":
    pAccuracy = []
    cAccuracy = []

    for i in range(5):
        nnet, p = testPenData()
        nnet, c = testCarData()
        pAccuracy.append(p)
        cAccuracy.append(c)

    print "PenData:"
    print "Max = " + str(max(pAccuracy))
    print "Average = " + str(average(pAccuracy))
    print "SD = " + str(stDeviation(pAccuracy))
    print "CarData:"
    print "Max = " + str(max(cAccuracy))
    print "Average = " + str(average(cAccuracy))
    print "SD = " + str(stDeviation(cAccuracy))
コード例 #10
0
ファイル: q5.py プロジェクト: jennifer-ma/code
avg = 0
stdev = 0
accuracyList = []  # both pen and data
accuracyListCar = []

for i in xrange(5):
    nnet, accuracy = testPenData()
    accuracyList.append(accuracy)
    if maximum < accuracy:
        maximum = accuracy

avg = average(accuracyList)
stdev = stDeviation(accuracyList)

for i in xrange(5):
    nnet, accuracy = testCarData()
    accuracyList.append(accuracy)
    accuracyListCar.append(accuracy)
    if maximumCar < accuracy:
        maximumCar = accuracy

avgCar = average(accuracyListCar)
stdevCar = stDeviation(accuracyListCar)
avgBoth = average(accuracyList)
stdevBoth = stDeviation(accuracyList)

print "maximum: ", maximum
print "avg: ", avg
print "stdev: ", stdev
print "\n"
コード例 #11
0
def randResTestCarData(randRestarts=1):
    testAccuracy = []
    for testNum in range(0, randRestarts):
        nnet, ta = testCarData()
        testAccuracy.append(ta)
    return testAccuracy
コード例 #12
0
from Testing import testPenData, testCarData, average, stDeviation
import csv
with open('Pen0.csv', 'wb') as csvfile:
    spamwriter = csv.writer(csvfile, delimiter=',',
                                    quotechar='|', quoting=csv.QUOTE_MINIMAL)
    spamwriter.writerow(['Data Type', 'Perceptrons', 'Average Accuracy', 'Standard Deviation', 'Maximum Accuracy'])

    for i in range(0, 9):
        penAccuracyList = []
        carAccuracyList = []
        for k in range(5):
            penAccuracyList.append(testPenData(hiddenLayers=[i * 5])[1])
            carAccuracyList.append(testCarData(hiddenLayers=[i * 5])[1])
        avgPen = average(penAccuracyList)
        stDevPen = stDeviation(penAccuracyList)
        maxPen = max(penAccuracyList)

        avgCar = average(carAccuracyList)
        stDevCar = stDeviation(carAccuracyList)
        maxCar = max(carAccuracyList)
        print "writing"
        spamwriter.writerow(['PenData', str(i * 5), str(avgPen), str(stDevPen), str(maxPen)])
        spamwriter.writerow(['Car Data', str(i * 5), str(avgCar), str(stDevCar), str(maxCar)])

コード例 #13
0
ファイル: q5q6.py プロジェクト: NateKnob/Fall17AI
    if len(sys.argv) == 1 or sys.argv[1] == "5":
        print("Q5")
        f = open("q5results.txt", "w")

        f.write("\n>>> QUESTION 5 Pen \n")
        ans = []
        for x in range(5):
            nnet, accuracy = testPenData(hiddenLayers = [24])
            ans.append(accuracy)
        results(ans, f)

        f.write("\n\n\n>>> QUESTION 5 Car \n")
        ans = []
        for x in range(5):
            nnet, accuracy = testCarData(hiddenLayers = [24])
            ans.append(accuracy)
        results(ans, f)

        f.close()

    if len(sys.argv) == 1 or sys.argv[1] == "6":
        print("Q6")

        pans = []
        for p in range(0, 41, 5):
            perp = []
            for x in range(5):
                print("P=" + str(p) + " I=" + str(x))
                nnet, accuracy = testPenData(hiddenLayers = [p])
                perp.append(accuracy)