class SVMDriver(Driver):
    def __init__(self):
        self.preProcessor = PreProcessor()
        self.svmProcessor = SVMProcessor()
        self.svmFeatureExtractor = SVMFeatureExtractor()

    def data_process(self, fileName):
        ListT, ListX, ListY, ListP = self.pre_process(fileName)
        ListR = self.svmProcessor.radius(ListX, ListY)
        ListVX = self.svmProcessor.velocity_of_x(ListX, ListT)
        ListVY = self.svmProcessor.velocity_of_y(ListY, ListT)
        ListVR = self.svmProcessor.velocity_of_r(ListR, ListT)
        ListVP = self.svmProcessor.velocity_of_p(ListP, ListT)
        ListAX = self.svmProcessor.acc_of_vx(ListVX, ListT)
        ListAY = self.svmProcessor.acc_of_vy(ListVY, ListT)
        ListAR = self.svmProcessor.acc_of_vr(ListVR, ListT)

        return ListT, ListX, ListY, ListP, ListR, ListVX, ListVY, ListVR, ListVP, ListAX, ListAY, ListAR

    def generate_features(self, fileName):
        ListT, ListX, ListY, ListR, ListP, ListVX, ListVY, ListVR, ListVP, ListAX, ListAY, ListAR = self.data_process(
            fileName
        )
        self.svmFeatureExtractor.generate_features(
            ListT, ListX, ListY, ListR, ListP, ListVX, ListVY, ListVR, ListVP, ListAX, ListAY, ListAR
        )
        return self.svmFeatureExtractor.features()

    def feature_clear(self):
        self.svmFeatureExtractor.clear()
Exemple #2
0
class SVMDriver(Driver):
    def __init__(self):
        self.preProcessor = PreProcessor()
        self.svmProcessor = SVMProcessor()
        self.svmFeatureExtractor = SVMFeatureExtractor()

    def data_process(self, fileName):
        ListT, ListX, ListY, ListP = self.pre_process(fileName)
        ListR = self.svmProcessor.radius(ListX, ListY)
        ListVX = self.svmProcessor.velocity_of_x(ListX, ListT)
        ListVY = self.svmProcessor.velocity_of_y(ListY, ListT)
        ListVR = self.svmProcessor.velocity_of_r(ListR, ListT)
        ListVP = self.svmProcessor.velocity_of_p(ListP, ListT)
        ListAX = self.svmProcessor.acc_of_vx(ListVX, ListT)
        ListAY = self.svmProcessor.acc_of_vy(ListVY, ListT)
        ListAR = self.svmProcessor.acc_of_vr(ListVR, ListT)

        return ListT, ListX, ListY, ListP, ListR, ListVX, ListVY, ListVR, \
                ListVP, ListAX, ListAY, ListAR

    def generate_features(self, fileName):
        ListT, ListX, ListY, ListR, ListP, ListVX, ListVY, ListVR, ListVP, \
                ListAX, ListAY, ListAR = self.data_process(fileName)
        self.svmFeatureExtractor.generate_features(ListT, ListX, ListY, ListR,
                                                   ListP, ListVX, ListVY,
                                                   ListVR, ListVP, ListAX,
                                                   ListAY, ListAR)
        return self.svmFeatureExtractor.features()

    def feature_clear(self):
        self.svmFeatureExtractor.clear()
Exemple #3
0
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))