Exemplo n.º 1
0
def to_epoch(anom):
    r = list()
    for a in anom:
        cur = list()
        for t in a:
            cur.append(utils.to_epoch(t))
        r.append(cur)
    return r
Exemplo n.º 2
0
def to_epoch(anom):
  r = list()
  for a in anom:
    cur = list()
    for t in a:
      cur.append(utils.to_epoch(t))
    r.append(cur)
  return r
Exemplo n.º 3
0
    def fit(self, X):
        """Fit detector.
        Parameters
        ----------
        X : dataframe of shape (n_samples, n_features)
            The input samples.
        """
        # a=str(ts[:,0])
        X = X.to_numpy()
        timestamp = np.asarray(X[:, 0].astype(np.datetime64))
        pca = IncrementalPCA(n_components=1)
        value = np.reshape(pca.fit_transform(X[:, 1:]), -1)
        X = pd.Series(value, index=timestamp)
        X.index = X.index.map(lambda d: to_epoch(str(d)))
        lts = TimeSeries(X.to_dict())
        self.ts = timestamp
        self.ts_value = value
        self.detector = anomaly_detector.AnomalyDetector(lts)

        return self