Exemple #1
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
Exemple #2
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