class ProbDriver(Driver): def __init__(self): self.svmProcessor = SVMProcessor() self.probFeatureExtractor = ProbFeatureExtractor() self.preProcessor = PreProcessor() def data_process(self, filePath): ListT, ListX, ListY, ListP = self.pre_process(filePath) ListR = self.svmProcessor.radius(ListX, ListY) ListVX = self.svmProcessor.velocity_of_x(ListX, ListT) ListVY = self.svmProcessor.velocity_of_y(ListY, ListT) ListAX = self.svmProcessor.acc_of_vx(ListVX, ListT) ListAY = self.svmProcessor.acc_of_vy(ListVY, ListT) return ListT, ListR, ListVX, ListVY, ListAX, ListAY def generate_features(self, filePath): ListT, ListR, ListVX, ListVY, ListAX, ListAY = self.data_process( filePath) self.probFeatureExtractor.generate_features(ListT, ListR, ListVX, ListVY, ListAX, ListAY) return self.probFeatureExtractor.features() def feature_clear(self): self.probFeatureExtractor.clear() def PS(self, F): P = [] for i in range(len(F)): p = numpy.exp(-1 * pow( (F[i] - self.meanF[i]), 2) / 2 / self.varF[i]) / numpy.sqrt( 2 * self.meanF[i] * self.varF[i]) P.append(p) # print [round(p, 11) for p in P] # print numpy.isnan(P) PArray = numpy.asarray(P) PArray[numpy.isnan(PArray)] = 0 return PArray.sum() def ps_temp(self, ListF): self.meanF = [] self.varF = [] Features = [] for F in ListF: for i in range(len(F)): if i >= len(Features): Features.append([]) Features[i].append(F[i]) for F in Features: self.meanF.append(numpy.mean(F)) self.varF.append(numpy.var(F))
class ProbDriver(Driver): def __init__(self): self.svmProcessor = SVMProcessor() self.probFeatureExtractor = ProbFeatureExtractor() self.preProcessor = PreProcessor() def data_process(self, filePath): ListT, ListX, ListY, ListP = self.pre_process(filePath) ListR = self.svmProcessor.radius(ListX, ListY) ListVX = self.svmProcessor.velocity_of_x(ListX, ListT) ListVY = self.svmProcessor.velocity_of_y(ListY, ListT) ListAX = self.svmProcessor.acc_of_vx(ListVX, ListT) ListAY = self.svmProcessor.acc_of_vy(ListVY, ListT) return ListT, ListR, ListVX, ListVY, ListAX, ListAY def generate_features(self, filePath): ListT, ListR, ListVX, ListVY, ListAX, ListAY = self.data_process(filePath) self.probFeatureExtractor.generate_features(ListT, ListR, ListVX, ListVY, ListAX, ListAY) return self.probFeatureExtractor.features() def feature_clear(self): self.probFeatureExtractor.clear() def PS(self, F): P = [] for i in range(len(F)): p = numpy.exp(-1 * pow((F[i] - self.meanF[i]), 2) / 2 / self.varF[i]) / numpy.sqrt( 2 * self.meanF[i] * self.varF[i] ) P.append(p) # print [round(p, 11) for p in P] # print numpy.isnan(P) PArray = numpy.asarray(P) PArray[numpy.isnan(PArray)] = 0 return PArray.sum() def ps_temp(self, ListF): self.meanF = [] self.varF = [] Features = [] for F in ListF: for i in range(len(F)): if i >= len(Features): Features.append([]) Features[i].append(F[i]) for F in Features: self.meanF.append(numpy.mean(F)) self.varF.append(numpy.var(F))
def __init__(self): self.svmProcessor = SVMProcessor() self.probFeatureExtractor = ProbFeatureExtractor() self.preProcessor = PreProcessor()