Ejemplo n.º 1
0
def getRabeData(sensors, length, shift=256):
    from abraxas4.abraxasFrame import AbraxasFrame
    b = AbraxasFrame(numIrSensors=10, numFrSensors=2, windowWidth=length, windowShift=shift, numFreqs=0, numCoeffs=0,
                          enaStatFeats=False, featNormMethod='none', trainFraction=2/3, waveletLvl1=False,
                          randomSortTT=False, classSortTT=True)

    b.setWindowFunction(functionName='rect', alpha=0.25)
    # b.plotWindowFunction()

    b.selectSensorSubset(selectedSensors=[False, False, False], sensorType='bno')
    b.selectSensorSubset(selectedSensors=[], sensorType='fr')
    b.selectSensorSubset(selectedSensors=sensors, sensorType='ir')
    #b.selectSensorSubset(selectedSensors=[2], sensorType='ir')

    b.addDataFiles(fileSourceName="igor2.txt", fileSourcePath="../", startTime=600, stopTime=6000, label=0)

    b.addDataFiles(fileSourceName="ankita_pos2_lrRl.txt", fileSourcePath="../", startTime=150, stopTime=2500, label=1)

    b.addDataFiles(fileSourceName="markus.txt", fileSourcePath="../", startTime=500, stopTime=3300, label=2)

    dataSet = b.readDataSet(checkData=False, equalLength=True)
    # dataSet := Array with shape dataSet[i][j, k], where i refers to the i-th file loaded, k indicates the sensor and
    #         j is the "time"-index.

    wData, wLabels = b.windowSplitSourceDataTT(inputData=dataSet, inputLabels=np.array([0, 1, 2]))

    wLabels = np.array(wLabels)
    print("Number of windows, Igor: ", str(np.size(wLabels[wLabels == 0])))
    print("Number of windows, Ankita: ", str(np.size(wLabels[wLabels == 1])))
    print("Number of windows, Markus: ", str(np.size(wLabels[wLabels == 2])))

    igor = []
    ankita = []
    markus = []

    #for i in range(len(wLabels)):
    #    wData[i] = wData[i]*(1+0*np.random.random([250, 1]))

    for i in range(len(wLabels)):
        if wLabels[i]==0:
            igor.append(wData[i]*1)
        if wLabels[i]==1:
            ankita.append(wData[i]*1)
        if wLabels[i]==2:
            markus.append(wData[i]*1)
    return igor, ankita, markus
Ejemplo n.º 2
0
               stopTime=6000,
               label=0)

b.addDataFiles(fileSourceName="ankita_pos2_lrRl.txt",
               fileSourcePath="../",
               startTime=150,
               stopTime=2500,
               label=1)

b.addDataFiles(fileSourceName="markus.txt",
               fileSourcePath="../",
               startTime=500,
               stopTime=3300,
               label=2)

dataSet = b.readDataSet(checkData=False, equalLength=True)
# dataSet := Array with shape dataSet[i][j, k], where i refers to the i-th file loaded, k indicates the sensor and
#         j is the "time"-index.

wData, wLabels = b.windowSplitSourceDataTT(inputData=dataSet,
                                           inputLabels=np.array([0, 1, 2]))

wLabels = np.array(wLabels)

print("Number of windows, Igor: ", str(np.size(wLabels[wLabels == 0])))
print("Number of windows, Ankita: ", str(np.size(wLabels[wLabels == 1])))
print("Number of windows, Markus: ", str(np.size(wLabels[wLabels == 2])))

igor = []
ankita = []
markus = []
Ejemplo n.º 3
0
                         label=5,
                         className="markus")

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

    xgbAbra.readDataSet(checkData=False, equalLength=False)

    xgbAbra.dumpTeTrData(dumpName='xgbAbra.pkl')

if dtAbra:
    dtAbra = AbraxasFrame(numIrSensors=10,
                          numFrSensors=2,
                          windowWidth=100,
                          windowShift=25,
                          numFreqs=1,
                          numCoeffs=0,
                          enaStatFeats=True,
                          featNormMethod='stand',
                          trainFraction=2 / 3,
                          waveletLvl1=False,
                          randomSortTT=False,
Ejemplo n.º 4
0
                fileSourcePath="../",
                startTime=13600,
                stopTime=13700,
                label=1)
oc.addDataFiles(fileSourceName="chrisOut2.txt",
                fileSourcePath="../",
                startTime=14350,
                stopTime=14550,
                label=1)
oc.addDataFiles(fileSourceName="chrisOut2.txt",
                fileSourcekPath="../",
                startTime=20300,
                stopTime=20400,
                label=1)

oc.readDataSet(equalLength=False, checkData=False)
oc.dumpTeTrData(dumpName="anomaly.pkl")

TrainFeat, TrainLabel, TestFeat, TestLabel = oc.loadTeTrDump(
    dumpName="anomaly.pkl")

data = np.concatenate([TestFeat, TrainFeat])
label = np.concatenate([TestLabel, TrainLabel])

normal = data[label == 0]
anomal = data[label == 1]

training = normal[0:int(2 / 3 * len(normal))]
test = normal[int(2 / 3 * len(normal))::]

from sklearn.svm import OneClassSVM
Ejemplo n.º 5
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()

Ejemplo n.º 6
0
abra.addDataFiles(fileSourceName="chrisOut2.txt", fileSourcePath="../", startTime=14000, stopTime=22000, label=2)

abra.addDataFiles(fileSourceName="chris_c.txt", fileSourcePath="../", startTime=100, stopTime=1600, label=3,
                     className="crooked")

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

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

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

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

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: