Example #1
0
                     className="chris")
gNbAbra.addDataFiles(fileSourceName="chris_pos2.txt", fileSourcePath="../", startTime=100, stopTime=1700, label=2)
gNbAbra.addDataFiles(fileSourceName="chris1.txt", fileSourcePath="../", startTime=500, stopTime=5000, label=2)
gNbAbra.addDataFiles(fileSourceName="chris2.txt", fileSourcePath="../", startTime=1000, stopTime=8600, label=2)
gNbAbra.addDataFiles(fileSourceName="chrisOut.txt", fileSourcePath="../", startTime=1000, stopTime=9000, label=2)
gNbAbra.addDataFiles(fileSourceName="chrisOut2.txt", fileSourcePath="../", startTime=1000, stopTime=4000, label=2)
gNbAbra.addDataFiles(fileSourceName="chrisOut2.txt", fileSourcePath="../", startTime=4250, stopTime=5250, label=2)
gNbAbra.addDataFiles(fileSourceName="chrisOut2.txt", fileSourcePath="../", startTime=6000, stopTime=14000, label=2)
gNbAbra.addDataFiles(fileSourceName="chrisOut2.txt", fileSourcePath="../", startTime=14000, stopTime=22000, label=2)
gNbAbra.addDataFiles(fileSourceName="chris_c.txt", fileSourcePath="../", startTime=100, stopTime=1600, label=3,
                     className="crooked")

gNbAbra.addDataFiles(fileSourceName="ben.txt", fileSourcePath="../", startTime=2000, stopTime=6000, label=4,
                     className="ben")

gNbAbra.addDataFiles(fileSourceName="markus.txt", fileSourcePath="../", startTime=500, stopTime=3300, label=5,
                     className="markus")

gNbAbra.addDataFiles(fileSourceName="igor.txt", fileSourcePath="../", startTime=100, stopTime=2900, label=6,
                     className="igor")
gNbAbra.addDataFiles(fileSourceName="igor2.txt", fileSourcePath="../", startTime=600, stopTime=6000, label=6)

gNbAbra.readDataSet(equalLength=False, checkData=True)

gNbAbra.initFeatNormalization(dumpName="throwAway")
from sklearn.naive_bayes import GaussianNB
clf = GaussianNB()
gNbAbra.trainClassifier(classifier=clf)
gNbAbra.testClassifier()

Example #2
0
                label=1)
oc.addDataFiles(fileSourceName="novcc.txt",
                fileSourcePath="../",
                startTime=0,
                stopTime=10000,
                label=1)
oc.addDataFiles(fileSourceName="nowalk.txt",
                fileSourcePath="../",
                startTime=0,
                stopTime=10000,
                label=1)
oc.addDataFiles(fileSourceName="nowalk2.txt",
                fileSourcePath="../",
                startTime=0,
                stopTime=10000,
                label=1)
oc.addDataFiles(fileSourceName="nowalk3.txt",
                fileSourcePath="../",
                startTime=0,
                stopTime=10000,
                label=1)

oc.readDataSet(equalLength=False, checkData=False)
oc.initFeatNormalization()

from sklearn.naive_bayes import GaussianNB
model = GaussianNB()

oc.trainClassifier(classifier=model)
oc.testClassifier()
Example #3
0
windowedData, windowLabels = abra.windowSplitSourceDataTT()

index = np.linspace(0, len(windowedData) - 1, len(windowedData), dtype=int)
random.shuffle(index)

trainingData = []
trainingLabels = []
testData = []
testLabels = []
for i in range(int(len(windowedData))):
    if i/len(windowedData) < 0.8:
        trainingData.append(windowedData[index[i]])
        trainingLabels.append(windowLabels[index[i]])
    else:
        testData.append(windowedData[index[i]])
        testLabels.append(windowLabels[index[i]])

trainingData = abra.initFeatNormalization(inputData=trainingData)

for i in range(len(testData)):
    testData[i] = abra.featureNormalization(features=abra.extractFeatures(data=testData[i]), initDone=True)

#model = xgboost.XGBClassifier(max_depth=3, learning_rate=0.3)
from sklearn.neural_network import MLPClassifier
model = MLPClassifier()
#from sklearn.neighbors import KNeighborsClassifier
#model = KNeighborsClassifier(n_neighbors=4, metric='euclidean')
kfold = StratifiedKFold(n_splits=3)
results = cross_val_score(model, np.array(trainingData), np.array(trainingLabels), cv=kfold)
print("Accuracy: %.2f%% (%.2f%%)" % (results.mean()*100, results.std()*100))