33# Copyright (c) 2023, 2024 Oracle and/or its affiliates.
44# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
55
6+ from ads .opctl .operator .lowcode .anomaly .const import NonTimeADSupportedModels
67import yaml
78import subprocess
89import pandas as pd
1617from ads .opctl .operator .cmd import run
1718
1819
19- MODELS = ["autots" ] # "automlx",
20+ MODELS = ["autots" , "oneclasssvm" , "isolationforest" ] # "automlx",
2021
2122# Mandatory YAML parameters
2223TEMPLATE_YAML = {
@@ -71,7 +72,8 @@ def test_artificial_big(model):
7172 df_i = pd .DataFrame (
7273 d1 , columns = [TARGET_COLUMN , "extra reg 1" , "extra reg 2" ]
7374 ) # columns=[f"sensor {i}", f"extra reg {i}-1", f"extra reg {i}-2"] # Uncomment for wide format
74- df_i [DATETIME_COLUMN ] = yr_in_30_min
75+ if model not in NonTimeADSupportedModels .values ():
76+ df_i [DATETIME_COLUMN ] = yr_in_30_min
7577 df_i [TARGET_CATEGORY_COLUMN ] = f"GHNI007894032{ i } "
7678 all_data .append (df_i )
7779
@@ -90,7 +92,10 @@ def test_artificial_big(model):
9092 yaml_i ["spec" ]["output_directory" ]["url" ] = output_dirname
9193 yaml_i ["spec" ]["target_column" ] = TARGET_COLUMN
9294 yaml_i ["spec" ]["target_category_columns" ] = [TARGET_CATEGORY_COLUMN ]
93- yaml_i ["spec" ]["datetime_column" ]["name" ] = DATETIME_COLUMN
95+ if model in NonTimeADSupportedModels .values ():
96+ del yaml_i ["spec" ]["datetime_column" ]
97+ else :
98+ yaml_i ["spec" ]["datetime_column" ]["name" ] = DATETIME_COLUMN
9499
95100 # run(yaml_i, backend="operator.local", debug=False)
96101
@@ -131,6 +136,8 @@ def test_artificial_small(model):
131136 yaml_i ["spec" ]["input_data" ]["url" ] = input_data
132137 yaml_i ["spec" ]["output_directory" ]["url" ] = output_dirname
133138 yaml_i ["spec" ]["contamination" ] = 0.3
139+ if model in NonTimeADSupportedModels .values ():
140+ del yaml_i ["spec" ]["datetime_column" ]
134141
135142 # run(yaml_i, debug=False)
136143
@@ -162,8 +169,9 @@ def test_validation(model):
162169 np .concatenate ([np .zeros (100 ), np .ones (2 ), np .zeros (100 )], axis = 0 ),
163170 columns = ["anomaly" ],
164171 )
165- d = d .reset_index ().rename ({"index" : "ds" }, axis = 1 )
166- anomaly_col ["ds" ] = d ["ds" ]
172+ if model not in NonTimeADSupportedModels .values ():
173+ d = d .reset_index ().rename ({"index" : "ds" }, axis = 1 )
174+ anomaly_col ["ds" ] = d ["ds" ]
167175 v = d .copy ()
168176 v ["anomaly" ] = anomaly_col ["anomaly" ]
169177 with tempfile .TemporaryDirectory () as tmpdirname :
@@ -185,6 +193,8 @@ def test_validation(model):
185193 yaml_i ["spec" ]["test_data" ] = {"url" : test_data }
186194 yaml_i ["spec" ]["output_directory" ]["url" ] = output_dirname
187195 yaml_i ["spec" ]["contamination" ] = 0.05
196+ if model in NonTimeADSupportedModels .values ():
197+ del yaml_i ["spec" ]["datetime_column" ]
188198
189199 # run(yaml_i, backend="operator.local", debug=False)
190200 with open (anomaly_yaml_filename , "w" ) as f :
@@ -207,7 +217,10 @@ def test_load_datasets(model, data_dict):
207217 yaml_i = deepcopy (TEMPLATE_YAML )
208218 yaml_i ["spec" ]["model" ] = model
209219 yaml_i ["spec" ]["input_data" ]["url" ] = data_dict ["url" ]
210- yaml_i ["spec" ]["datetime_column" ]["name" ] = data_dict ["dt_col" ]
220+ if model in NonTimeADSupportedModels .values ():
221+ del yaml_i ["spec" ]["datetime_column" ]
222+ else :
223+ yaml_i ["spec" ]["datetime_column" ]["name" ] = data_dict ["dt_col" ]
211224 yaml_i ["spec" ]["output_directory" ]["url" ] = output_dirname
212225
213226 # run(yaml_i, backend="operator.local", debug=False)
0 commit comments