예제 #1
0
def prepare_segment2(func, dtype, datasetdscr):
    segmentor = func.segmentor

    func.activityFetcher.precompute(dtype)

    procdata = Data(segmentor.__str__())
    procdata.generator = segment2(dtype, datasetdscr, segmentor)
    procdata.set = []
    procdata.label = []
    procdata.set_window = []
    procdata.acts = func.acts
    procdata.s_events = dtype.s_events
    procdata.s_event_list = dtype.s_event_list
    procdata.a_events = dtype.a_events

    i = 0
    for x in procdata.generator:
        if i % 10000 == 0:
            print(segmentor.shortname(), i)
        i += 1
        procdata.set_window.append(x)
        procdata.label.append(
            func.activityFetcher.getActivity2(dtype.s_event_list, x))
    del procdata.generator
    procdata.label = np.array(procdata.label)

    return procdata
예제 #2
0
 def process(self, datasetdscr, dataset):
     removekeys = []
     for sid, info in datasetdscr.sensor_desc.iterrows():
         last = {}
         last['value'] = -1000
         if (info.Nominal | info.OnChange):
             continue
         xs = dataset.s_events.loc[dataset.s_events.SID == sid]
         min = xs.value.min()
         max = xs.value.max()
         #print(min, max, max-min)
         invalid_changes = (max - min) * 0.1
         for key, event in xs.iterrows():
             invalid_changes = event['value'] * .1
             if abs(last['value'] - event['value']) < invalid_changes:
                 #print (event)
                 removekeys.append(key)
                 continue
             last = event
         # print(removekeys)
     d = Data(dataset.name)
     d.s_events = dataset.s_events.drop(removekeys)
     d.a_events = dataset.a_events
     d.s_event_list = d.s_events.values
     d.acts = dataset.acts
     d.act_map = dataset.act_map
     return d
예제 #3
0
    def justifySet(self, acts, Train, add_other_action=False):
        inp = [Train]
        out = []
        if (acts[0] != 0):
            acts.insert(0, 0)

        act_map = {a: i for i, a in enumerate(acts)}
        for dtype in inp:
            ndtype = Data(dtype.name)
            ndtype.s_events = dtype.s_events
            ndtype.a_events = dtype.a_events.copy()
            ndtype.a_events.Activity = dtype.a_events.Activity.apply(
                lambda x: act_map[x]
                if x in act_map else (len(acts) if add_other_action else 0))

            out.append(ndtype)
            ndtype.act_map = act_map
            ndtype.acts = acts
        return out[0]  #Train