Example #1
0
    def __init__(self, filename):
        """Input: path and name of the file of a trace; how many filtering steps should be used for sliding window filtering"""
        self.__id = int(os.path.basename(filename).split(".")[0])
        x = []
        y = []
        with open(filename, "r") as trainfile:
            trainfile.readline()  # skip header
            for line in trainfile:
                items = line.split(",", 2)
                x.append(float(items[0]))
                y.append(float(items[1]))
        triplength = distance(x[0], y[0], x[-1], y[-1])
        self.triptime = len(x)
        xvar, yvar = bettervariance(x, y)
        overlaps = overlap(x, y)
        self.featurelist = []
        self.featurelist.append(triplength)
        self.featurelist.append(self.triptime)
        self.featurelist.append(xvar)
        self.featurelist.append(yvar)
        self.featurelist.append(overlaps)

        v, distancecovered = velocities_and_distance_covered(x, y)
        vfiltered = reject_outliers(v, 3)
        maxspeed = max(vfiltered)
        medianspeed = median(vfiltered)
        meanspeed, varspeed = meanstdv(vfiltered)
        angles, jumps = self.angles_and_jumps()
        anglespeed = [speed * angle for (speed, angle) in zip(v, angles)]
        anglespeedfiltered  = reject_outliers(anglespeed, 3)
        maxanglespeed = max(anglespeedfiltered)
        mediananglespeed = median(anglespeedfiltered)
        meananglespeed, varanglespeed = meanstdv(anglespeedfiltered)
        totalangle = sum(angles)
        maxangle = max(angles)
        minangle = min(angles)
        medianangle = max(angles)
        acc, dec, stills = getratio(vfiltered, medianspeed)
        if (acc + dec) == 0:
            accratio = 0.5
        else:
            accratio = acc / (acc + dec)
        self.featurelist.append(distancecovered)
        self.featurelist.append(maxspeed)
        self.featurelist.append(medianspeed)
        self.featurelist.append(meanspeed)
        self.featurelist.append(varspeed)
        self.featurelist.append(maxanglespeed)
        self.featurelist.append(mediananglespeed)
        self.featurelist.append(meananglespeed)
        self.featurelist.append(varanglespeed)
        self.featurelist.append(totalangle)
        self.featurelist.append(medianangle)
        self.featurelist.append(maxangle)
        self.featurelist.append(minangle)
        self.featurelist.append(jumps)
        self.featurelist.append(accratio)
        self.featurelist.append(acc)
        self.featurelist.append(dec)
        self.featurelist.append(stills)
Example #2
0
    def __init__(self, filename, quantiles=[0.0, 0.25, 0.5, 0.75, 1.0]):
        """Input: path and name of the file of a trace; how many filtering steps should be used for sliding window filtering"""
        self.__id = int(os.path.basename(filename).split(".")[0])
        self._x = []
        self._y = []
        with open(filename, "r") as trainfile:
            trainfile.readline()  # skip header
            for line in trainfile:
                items = line.split(",", 2)
                self._x.append(float(items[0]))
                self._y.append(float(items[1]))
        self.rawfeaturelist = []
        self.rawfeaturelist.extend(self._x)
        self.rawfeaturelist.extend(self._y)
        triplength = distance(self._x[0], self._y[0], self._x[-1], self._y[-1])
        self.triptime = len(self._x)
        xvar, yvar = bettervariance(self._x, self._y)
        overlaps = overlap(self._x, self._y)
        self.featurelist = []
        self.featurelist.append(triplength)
        self.featurelist.append(self.triptime)
        self.featurelist.append(xvar)
        self.featurelist.append(yvar)
        self.featurelist.append(overlaps)

        v, distancecovered = velocities_and_distance_covered(self._x, self._y)
        vfiltered = reject_outliers(v, 3)
        self.rawfeaturelist.extend(vfiltered)
        speed_qs = mquantiles(vfiltered, prob=quantiles)
        angles, jumps = self.angles_and_jumps()
        self.rawfeaturelist.extend(angles)
        anglespeed = [speed * angle for (speed, angle) in zip(v, angles)]
        anglespeedfiltered = reject_outliers(anglespeed, 3)
        anglespeed_qs = mquantiles(anglespeedfiltered, prob=quantiles)
        totalangle = sum(angles)
        angle_qs = mquantiles(angles, prob=quantiles)
        acc, dec, stills = getratio(vfiltered, anglespeed_qs[2])

        self.featurelist.append(distancecovered)
        self.featurelist.extend(speed_qs)
        self.featurelist.extend(anglespeed_qs)
        self.featurelist.append(totalangle)
        self.featurelist.extend(angle_qs)
        self.featurelist.append(acc)
        self.featurelist.append(dec)
        self.featurelist.append(stills)
Example #3
0
    def __init__(self, filename, quantiles=[0.0, 0.25, 0.5, 0.75, 1.0]):
        """Input: path and name of the file of a trace; how many filtering steps should be used for sliding window filtering"""
        self.__id = int(os.path.basename(filename).split(".")[0])
        self._x = []
        self._y = []
        with open(filename, "r") as trainfile:
            trainfile.readline()  # skip header
            for line in trainfile:
                items = line.split(",", 2)
                self._x.append(float(items[0]))
                self._y.append(float(items[1]))
        self.rawfeaturelist = []
        self.rawfeaturelist.extend(self._x)
        self.rawfeaturelist.extend(self._y)
        triplength = distance(self._x[0], self._y[0], self._x[-1], self._y[-1])
        self.triptime = len(self._x)
        xvar, yvar = bettervariance(self._x, self._y)
        overlaps = overlap(self._x, self._y)
        self.featurelist = []
        self.featurelist.append(triplength)
        self.featurelist.append(self.triptime)
        self.featurelist.append(xvar)
        self.featurelist.append(yvar)
        self.featurelist.append(overlaps)

        v, distancecovered = velocities_and_distance_covered(self._x, self._y)
        vfiltered = reject_outliers(v, 3)
        self.rawfeaturelist.extend(vfiltered)
        speed_qs = mquantiles(vfiltered, prob=quantiles)
        angles, jumps = self.angles_and_jumps()
        self.rawfeaturelist.extend(angles)
        anglespeed = [speed * angle for (speed, angle) in zip(v, angles)]
        anglespeedfiltered = reject_outliers(anglespeed, 3)
        anglespeed_qs = mquantiles(anglespeedfiltered, prob=quantiles)
        totalangle = sum(angles)
        angle_qs = mquantiles(angles, prob=quantiles)
        acc, dec, stills = getratio(vfiltered, anglespeed_qs[2])

        self.featurelist.append(distancecovered)
        self.featurelist.extend(speed_qs)
        self.featurelist.extend(anglespeed_qs)
        self.featurelist.append(totalangle)
        self.featurelist.extend(angle_qs)
        self.featurelist.append(acc)
        self.featurelist.append(dec)
        self.featurelist.append(stills)