コード例 #1
0
ファイル: anomaly.py プロジェクト: zerofang/binet
    def generate_random_event(self):
        if self.activities is None:
            raise RuntimeError('activities has not bee set.')

        event = Event(name=f'Random activity {np.random.randint(1, len(self.activities))}')
        if self.attributes is not None:
            event.attributes = dict(
                (a.name, f'Random {a.name} {np.random.randint(1, len(a.values))}') for a in self.attributes)
        return event
コード例 #2
0
 def generate_random_event_v2(self, act):
     if self.activities is None:
         raise RuntimeError('activities has not bee set.')
     actset = [x for x in self.activities if x not in act]
     event = Event(name=f'{np.random.choice(actset)}')
     if self.attributes is not None:
         event.attributes = dict(
             (a.name, f'Random {a.name} {np.random.randint(1, 3)}')
             for a in self.attributes)
     return event