Skip to content

Commit 4679082

Browse files
committed
format with ruff
1 parent 7468503 commit 4679082

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

ads/opctl/operator/lowcode/anomaly/model/anomaly_merlion.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*--
32

43
# Copyright (c) 2023, 2024 Oracle and/or its affiliates.
54
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
65

76
import importlib
8-
from collections import defaultdict
97

108
import numpy as np
119
import pandas as pd
@@ -100,20 +98,24 @@ def _build_model(self) -> AnomalyOutput:
10098
for model_name, (model_config, model) in model_config_map.items():
10199
model_config = model_config(**self.spec.model_kwargs)
102100
if hasattr(model_config, "target_seq_index"):
103-
model_config.target_seq_index = df.columns.get_loc(self.spec.target_column)
101+
model_config.target_seq_index = df.columns.get_loc(
102+
self.spec.target_column
103+
)
104104
model = model(model_config)
105105

106-
107106
scores = model.train(train_data=data, anomaly_labels=None)
108107

109108
try:
110109
y_pred = model.get_anomaly_label(data)
111-
y_pred =(y_pred.to_pd().reset_index()["anom_score"] > 0).astype(int)
110+
y_pred = (
111+
y_pred.to_pd().reset_index()["anom_score"] > 0
112+
).astype(int)
112113
except Exception as e:
113114
y_pred = (
114115
scores.to_pd().reset_index()["anom_score"]
115116
> np.percentile(
116-
scores.to_pd().reset_index()["anom_score"], anomaly_threshold
117+
scores.to_pd().reset_index()["anom_score"],
118+
anomaly_threshold,
117119
)
118120
).astype(int)
119121

tests/operators/anomaly/test_anomaly_simple.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454

5555
MODELS = ["autots", "oneclasssvm", "isolationforest", "randomcutforest"]
5656

57+
5758
@pytest.mark.parametrize("model", ["autots", "merlion_ad"])
5859
def test_artificial_big(model):
5960
all_data = []

0 commit comments

Comments
 (0)