oracle-ads 2.11.19__py3-none-any.whl → 2.12.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ads/aqua/config/evaluation/evaluation_service_config.py +1 -0
- ads/aqua/extension/model_handler.py +17 -21
- ads/aqua/model/constants.py +3 -1
- ads/llm/__init__.py +10 -4
- ads/llm/chat_template.py +31 -0
- ads/llm/guardrails/base.py +3 -2
- ads/llm/guardrails/huggingface.py +1 -1
- ads/llm/langchain/plugins/chat_models/__init__.py +5 -0
- ads/llm/langchain/plugins/chat_models/oci_data_science.py +924 -0
- ads/llm/langchain/plugins/llms/__init__.py +5 -0
- ads/llm/langchain/plugins/llms/oci_data_science_model_deployment_endpoint.py +939 -0
- ads/llm/requirements.txt +2 -2
- ads/llm/serialize.py +3 -6
- ads/llm/templates/tool_chat_template_hermes.jinja +130 -0
- ads/llm/templates/tool_chat_template_mistral_parallel.jinja +94 -0
- ads/opctl/operator/lowcode/anomaly/const.py +7 -2
- ads/opctl/operator/lowcode/anomaly/model/autots.py +30 -35
- ads/opctl/operator/lowcode/anomaly/model/factory.py +9 -8
- ads/opctl/operator/lowcode/anomaly/schema.yaml +8 -2
- ads/opctl/operator/lowcode/forecast/MLoperator +3 -3
- ads/opctl/operator/lowcode/forecast/model/automlx.py +1 -1
- ads/opctl/operator/lowcode/forecast/model/forecast_datasets.py +1 -1
- {oracle_ads-2.11.19.dist-info → oracle_ads-2.12.1.dist-info}/METADATA +6 -4
- {oracle_ads-2.11.19.dist-info → oracle_ads-2.12.1.dist-info}/RECORD +27 -25
- ads/llm/langchain/plugins/base.py +0 -118
- ads/llm/langchain/plugins/contant.py +0 -44
- ads/llm/langchain/plugins/embeddings.py +0 -64
- ads/llm/langchain/plugins/llm_gen_ai.py +0 -301
- ads/llm/langchain/plugins/llm_md.py +0 -316
- {oracle_ads-2.11.19.dist-info → oracle_ads-2.12.1.dist-info}/LICENSE.txt +0 -0
- {oracle_ads-2.11.19.dist-info → oracle_ads-2.12.1.dist-info}/WHEEL +0 -0
- {oracle_ads-2.11.19.dist-info → oracle_ads-2.12.1.dist-info}/entry_points.txt +0 -0
ads/llm/requirements.txt
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
langchain>=0.
|
2
|
-
pydantic>=
|
1
|
+
langchain>=0.3
|
2
|
+
pydantic>=2,<3
|
3
3
|
typing-extensions>=4.2.0
|
ads/llm/serialize.py
CHANGED
@@ -12,7 +12,6 @@ from typing import Any, Dict, List, Optional
|
|
12
12
|
import fsspec
|
13
13
|
import yaml
|
14
14
|
from langchain import llms
|
15
|
-
from langchain.chains import RetrievalQA
|
16
15
|
from langchain.chains.loading import load_chain_from_config
|
17
16
|
from langchain.llms import loading
|
18
17
|
from langchain.load.load import Reviver
|
@@ -21,7 +20,7 @@ from langchain.schema.runnable import RunnableParallel
|
|
21
20
|
|
22
21
|
from ads.common.auth import default_signer
|
23
22
|
from ads.common.object_storage_details import ObjectStorageDetails
|
24
|
-
from ads.llm import
|
23
|
+
from ads.llm import OCIModelDeploymentVLLM, OCIModelDeploymentTGI
|
25
24
|
from ads.llm.chain import GuardrailSequence
|
26
25
|
from ads.llm.guardrails.base import CustomGuardrailBase
|
27
26
|
from ads.llm.serializers.runnable_parallel import RunnableParallelSerializer
|
@@ -29,9 +28,8 @@ from ads.llm.serializers.retrieval_qa import RetrievalQASerializer
|
|
29
28
|
|
30
29
|
# This is a temp solution for supporting custom LLM in legacy load_chain
|
31
30
|
__lc_llm_dict = llms.get_type_to_cls_dict()
|
32
|
-
__lc_llm_dict[
|
33
|
-
__lc_llm_dict[
|
34
|
-
__lc_llm_dict[ModelDeploymentVLLM.__name__] = lambda: ModelDeploymentVLLM
|
31
|
+
__lc_llm_dict[OCIModelDeploymentTGI.__name__] = lambda: OCIModelDeploymentTGI
|
32
|
+
__lc_llm_dict[OCIModelDeploymentVLLM.__name__] = lambda: OCIModelDeploymentVLLM
|
35
33
|
|
36
34
|
|
37
35
|
def __new_type_to_cls_dict():
|
@@ -47,7 +45,6 @@ custom_serialization = {
|
|
47
45
|
GuardrailSequence: GuardrailSequence.save,
|
48
46
|
CustomGuardrailBase: CustomGuardrailBase.save,
|
49
47
|
RunnableParallel: RunnableParallelSerializer.save,
|
50
|
-
RetrievalQA: RetrievalQASerializer.save,
|
51
48
|
}
|
52
49
|
|
53
50
|
# Mapping _type to custom deserialization functions
|
@@ -0,0 +1,130 @@
|
|
1
|
+
{%- macro json_to_python_type(json_spec) %}
|
2
|
+
{%- set basic_type_map = {
|
3
|
+
"string": "str",
|
4
|
+
"number": "float",
|
5
|
+
"integer": "int",
|
6
|
+
"boolean": "bool"
|
7
|
+
} %}
|
8
|
+
|
9
|
+
{%- if basic_type_map[json_spec.type] is defined %}
|
10
|
+
{{- basic_type_map[json_spec.type] }}
|
11
|
+
{%- elif json_spec.type == "array" %}
|
12
|
+
{{- "list[" + json_to_python_type(json_spec|items) + "]" }}
|
13
|
+
{%- elif json_spec.type == "object" %}
|
14
|
+
{%- if json_spec.additionalProperties is defined %}
|
15
|
+
{{- "dict[str, " + json_to_python_type(json_spec.additionalProperties) + ']' }}
|
16
|
+
{%- else %}
|
17
|
+
{{- "dict" }}
|
18
|
+
{%- endif %}
|
19
|
+
{%- elif json_spec.type is iterable %}
|
20
|
+
{{- "Union[" }}
|
21
|
+
{%- for t in json_spec.type %}
|
22
|
+
{{- json_to_python_type({"type": t}) }}
|
23
|
+
{%- if not loop.last %}
|
24
|
+
{{- "," }}
|
25
|
+
{%- endif %}
|
26
|
+
{%- endfor %}
|
27
|
+
{{- "]" }}
|
28
|
+
{%- else %}
|
29
|
+
{{- "Any" }}
|
30
|
+
{%- endif %}
|
31
|
+
{%- endmacro %}
|
32
|
+
|
33
|
+
|
34
|
+
{{- bos_token }}
|
35
|
+
{{- "<|im_start|>system\nYou are a function calling AI model. You are provided with function signatures within <tools></tools> XML tags. You may call one or more functions to assist with the user query. Don't make assumptions about what values to plug into functions. Here are the available tools: <tools> " }}
|
36
|
+
{%- if tools is iterable and tools | length > 0 %}
|
37
|
+
{%- for tool in tools %}
|
38
|
+
{%- if tool.function is defined %}
|
39
|
+
{%- set tool = tool.function %}
|
40
|
+
{%- endif %}
|
41
|
+
{{- '{"type": "function", "function": ' }}
|
42
|
+
{{- '{"name": "' + tool.name + '", ' }}
|
43
|
+
{{- '"description": "' + tool.name + '(' }}
|
44
|
+
{%- for param_name, param_fields in tool.parameters.properties|items %}
|
45
|
+
{{- param_name + ": " + json_to_python_type(param_fields) }}
|
46
|
+
{%- if not loop.last %}
|
47
|
+
{{- ", " }}
|
48
|
+
{%- endif %}
|
49
|
+
{%- endfor %}
|
50
|
+
{{- ")" }}
|
51
|
+
{%- if tool.return is defined %}
|
52
|
+
{{- " -> " + json_to_python_type(tool.return) }}
|
53
|
+
{%- endif %}
|
54
|
+
{{- " - " + tool.description + "\n\n" }}
|
55
|
+
{%- for param_name, param_fields in tool.parameters.properties|items %}
|
56
|
+
{%- if loop.first %}
|
57
|
+
{{- " Args:\n" }}
|
58
|
+
{%- endif %}
|
59
|
+
{{- " " + param_name + "(" + json_to_python_type(param_fields) + "): " + param_fields.description|trim }}
|
60
|
+
{%- endfor %}
|
61
|
+
{%- if tool.return is defined and tool.return.description is defined %}
|
62
|
+
{{- "\n Returns:\n " + tool.return.description }}
|
63
|
+
{%- endif %}
|
64
|
+
{{- '"' }}
|
65
|
+
{{- ', "parameters": ' }}
|
66
|
+
{%- if tool.parameters.properties | length == 0 %}
|
67
|
+
{{- "{}" }}
|
68
|
+
{%- else %}
|
69
|
+
{{- tool.parameters|tojson }}
|
70
|
+
{%- endif %}
|
71
|
+
{{- "}" }}
|
72
|
+
{%- if not loop.last %}
|
73
|
+
{{- "\n" }}
|
74
|
+
{%- endif %}
|
75
|
+
{%- endfor %}
|
76
|
+
{%- endif %}
|
77
|
+
{{- " </tools>" }}
|
78
|
+
{{- 'Use the following pydantic model json schema for each tool call you will make: {"properties": {"name": {"title": "Name", "type": "string"}, "arguments": {"title": "Arguments", "type": "object"}}, "required": ["name", "arguments"], "title": "FunctionCall", "type": "object"}}
|
79
|
+
' }}
|
80
|
+
{{- "For each function call return a json object with function name and arguments within <tool_call></tool_call> XML tags as follows:
|
81
|
+
" }}
|
82
|
+
{{- "<tool_call>
|
83
|
+
" }}
|
84
|
+
{{- '{"name": <function-name>, "arguments": <args-dict>}
|
85
|
+
' }}
|
86
|
+
{{- '</tool_call><|im_end|>' }}
|
87
|
+
{%- for message in messages %}
|
88
|
+
{%- if message.role == "user" or message.role == "system" or (message.role == "assistant" and message.tool_calls is not defined) %}
|
89
|
+
{{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
|
90
|
+
{%- elif message.role == "assistant" and message.tool_calls is defined %}
|
91
|
+
{{- '<|im_start|>' + message.role }}
|
92
|
+
{%- for tool_call in message.tool_calls %}
|
93
|
+
{{- '\n<tool_call>\n' }}
|
94
|
+
{%- if tool_call.function is defined %}
|
95
|
+
{%- set tool_call = tool_call.function %}
|
96
|
+
{%- endif %}
|
97
|
+
{{- '{' }}
|
98
|
+
{{- '"name": "' }}
|
99
|
+
{{- tool_call.name }}
|
100
|
+
{{- '"' }}
|
101
|
+
{%- if tool_call.arguments is defined %}
|
102
|
+
{{- ', ' }}
|
103
|
+
{{- '"arguments": ' }}
|
104
|
+
{{- tool_call.arguments|tojson }}
|
105
|
+
{%- endif %}
|
106
|
+
{{- '}' }}
|
107
|
+
{{- '\n</tool_call>' }}
|
108
|
+
{%- endfor %}
|
109
|
+
{{- '<|im_end|>\n' }}
|
110
|
+
{%- elif message.role == "tool" %}
|
111
|
+
{%- if loop.previtem and loop.previtem.role != "tool" %}
|
112
|
+
{{- '<|im_start|>tool\n' }}
|
113
|
+
{%- endif %}
|
114
|
+
{{- '<tool_response>\n' }}
|
115
|
+
{{- message.content }}
|
116
|
+
{%- if not loop.last %}
|
117
|
+
{{- '\n</tool_response>\n' }}
|
118
|
+
{%- else %}
|
119
|
+
{{- '\n</tool_response>' }}
|
120
|
+
{%- endif %}
|
121
|
+
{%- if not loop.last and loop.nextitem.role != "tool" %}
|
122
|
+
{{- '<|im_end|>' }}
|
123
|
+
{%- elif loop.last %}
|
124
|
+
{{- '<|im_end|>' }}
|
125
|
+
{%- endif %}
|
126
|
+
{%- endif %}
|
127
|
+
{%- endfor %}
|
128
|
+
{%- if add_generation_prompt %}
|
129
|
+
{{- '<|im_start|>assistant\n' }}
|
130
|
+
{%- endif %}
|
@@ -0,0 +1,94 @@
|
|
1
|
+
{%- if messages[0]["role"] == "system" %}
|
2
|
+
{%- set system_message = messages[0]["content"] %}
|
3
|
+
{%- set loop_messages = messages[1:] %}
|
4
|
+
{%- else %}
|
5
|
+
{%- set loop_messages = messages %}
|
6
|
+
{%- endif %}
|
7
|
+
{%- if not tools is defined %}
|
8
|
+
{%- set tools = none %}
|
9
|
+
{%- endif %}
|
10
|
+
{%- if tools is defined %}
|
11
|
+
{%- set parallel_tool_prompt = "You are a helpful assistant that can call tools. If you call one or more tools, format them in a single JSON array or objects, where each object is a tool call, not as separate objects outside of an array or multiple arrays. Use the format [{\"name\": tool call name, \"arguments\": tool call arguments}, additional tool calls] if you call more than one tool. If you call tools, do not attempt to interpret them or otherwise provide a response until you receive a tool call result that you can interpret for the user." %}
|
12
|
+
{%- if system_message is defined %}
|
13
|
+
{%- set system_message = parallel_tool_prompt + "\n\n" + system_message %}
|
14
|
+
{%- else %}
|
15
|
+
{%- set system_message = parallel_tool_prompt %}
|
16
|
+
{%- endif %}
|
17
|
+
{%- endif %}
|
18
|
+
{%- set user_messages = loop_messages | selectattr("role", "equalto", "user") | list %}
|
19
|
+
|
20
|
+
{%- for message in loop_messages | rejectattr("role", "equalto", "tool") | rejectattr("role", "equalto", "tool_results") | selectattr("tool_calls", "undefined") %}
|
21
|
+
{%- if (message["role"] == "user") != (loop.index0 % 2 == 0) %}
|
22
|
+
{{- raise_exception("After the optional system message, conversation roles must alternate user/assistant/user/assistant/...") }}
|
23
|
+
{%- endif %}
|
24
|
+
{%- endfor %}
|
25
|
+
|
26
|
+
{{- bos_token }}
|
27
|
+
{%- for message in loop_messages %}
|
28
|
+
{%- if message["role"] == "user" %}
|
29
|
+
{%- if tools is not none and (message == user_messages[-1]) %}
|
30
|
+
{{- "[AVAILABLE_TOOLS] [" }}
|
31
|
+
{%- for tool in tools %}
|
32
|
+
{%- set tool = tool.function %}
|
33
|
+
{{- '{"type": "function", "function": {' }}
|
34
|
+
{%- for key, val in tool.items() if key != "return" %}
|
35
|
+
{%- if val is string %}
|
36
|
+
{{- '"' + key + '": "' + val + '"' }}
|
37
|
+
{%- else %}
|
38
|
+
{{- '"' + key + '": ' + val|tojson }}
|
39
|
+
{%- endif %}
|
40
|
+
{%- if not loop.last %}
|
41
|
+
{{- ", " }}
|
42
|
+
{%- endif %}
|
43
|
+
{%- endfor %}
|
44
|
+
{{- "}}" }}
|
45
|
+
{%- if not loop.last %}
|
46
|
+
{{- ", " }}
|
47
|
+
{%- else %}
|
48
|
+
{{- "]" }}
|
49
|
+
{%- endif %}
|
50
|
+
{%- endfor %}
|
51
|
+
{{- "[/AVAILABLE_TOOLS]" }}
|
52
|
+
{%- endif %}
|
53
|
+
{%- if loop.last and system_message is defined %}
|
54
|
+
{{- "[INST] " + system_message + "\n\n" + message["content"] + "[/INST]" }}
|
55
|
+
{%- else %}
|
56
|
+
{{- "[INST] " + message["content"] + "[/INST]" }}
|
57
|
+
{%- endif %}
|
58
|
+
{%- elif message["role"] == "tool_calls" or message.tool_calls is defined %}
|
59
|
+
{%- if message.tool_calls is defined %}
|
60
|
+
{%- set tool_calls = message.tool_calls %}
|
61
|
+
{%- else %}
|
62
|
+
{%- set tool_calls = message.content %}
|
63
|
+
{%- endif %}
|
64
|
+
{{- "[TOOL_CALLS] [" }}
|
65
|
+
{%- for tool_call in tool_calls %}
|
66
|
+
{%- set out = tool_call.function|tojson %}
|
67
|
+
{{- out[:-1] }}
|
68
|
+
{%- if not tool_call.id is defined or tool_call.id|length < 9 %}
|
69
|
+
{{- raise_exception("Tool call IDs should be alphanumeric strings with length >= 9! (1)" + tool_call.id) }}
|
70
|
+
{%- endif %}
|
71
|
+
{{- ', "id": "' + tool_call.id[-9:] + '"}' }}
|
72
|
+
{%- if not loop.last %}
|
73
|
+
{{- ", " }}
|
74
|
+
{%- else %}
|
75
|
+
{{- "]" + eos_token }}
|
76
|
+
{%- endif %}
|
77
|
+
{%- endfor %}
|
78
|
+
{%- elif message["role"] == "assistant" %}
|
79
|
+
{{- " " + message["content"] + eos_token }}
|
80
|
+
{%- elif message["role"] == "tool_results" or message["role"] == "tool" %}
|
81
|
+
{%- if message.content is defined and message.content.content is defined %}
|
82
|
+
{%- set content = message.content.content %}
|
83
|
+
{%- else %}
|
84
|
+
{%- set content = message.content %}
|
85
|
+
{%- endif %}
|
86
|
+
{{- '[TOOL_RESULTS] {"content": ' + content|string + ", " }}
|
87
|
+
{%- if not message.tool_call_id is defined or message.tool_call_id|length < 9 %}
|
88
|
+
{{- raise_exception("Tool call IDs should be alphanumeric strings with length >= 9! (2)" + message.tool_call_id) }}
|
89
|
+
{%- endif %}
|
90
|
+
{{- '"call_id": "' + message.tool_call_id[-9:] + '"}[/TOOL_RESULTS]' }}
|
91
|
+
{%- else %}
|
92
|
+
{{- raise_exception("Only user and assistant roles are supported, with the exception of an initial optional system message!") }}
|
93
|
+
{%- endif %}
|
94
|
+
{%- endfor %}
|
@@ -11,10 +11,15 @@ from ads.opctl.operator.lowcode.common.const import DataColumns
|
|
11
11
|
class SupportedModels(str, metaclass=ExtendedEnumMeta):
|
12
12
|
"""Supported anomaly models."""
|
13
13
|
|
14
|
-
AutoMLX = "automlx"
|
15
14
|
AutoTS = "autots"
|
16
15
|
Auto = "auto"
|
17
|
-
|
16
|
+
IQR = "iqr"
|
17
|
+
LOF = "lof"
|
18
|
+
ZSCORE = "zscore"
|
19
|
+
ROLLING_ZSCORE = "rolling_zscore"
|
20
|
+
MAD = "mad"
|
21
|
+
EE = "ee"
|
22
|
+
ISOLATIONFOREST = "isolationforest"
|
18
23
|
|
19
24
|
class NonTimeADSupportedModels(str, metaclass=ExtendedEnumMeta):
|
20
25
|
"""Supported non time-based anomaly detection models."""
|
@@ -4,50 +4,51 @@
|
|
4
4
|
# Copyright (c) 2023, 2024 Oracle and/or its affiliates.
|
5
5
|
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
|
6
6
|
|
7
|
-
import pandas as pd
|
8
|
-
|
9
7
|
from ads.common.decorator.runtime_dependency import runtime_dependency
|
10
|
-
|
11
|
-
from .base_model import AnomalyOperatorBaseModel
|
12
|
-
from .anomaly_dataset import AnomalyOutput
|
13
8
|
from ads.opctl.operator.lowcode.anomaly.const import OutputColumns
|
9
|
+
from .anomaly_dataset import AnomalyOutput
|
10
|
+
from .base_model import AnomalyOperatorBaseModel
|
11
|
+
from ..const import SupportedModels
|
12
|
+
from ads.opctl import logger
|
14
13
|
|
15
14
|
|
16
15
|
class AutoTSOperatorModel(AnomalyOperatorBaseModel):
|
17
16
|
"""Class representing AutoTS Anomaly Detection operator model."""
|
17
|
+
model_mapping = {
|
18
|
+
"isolationforest": "IsolationForest",
|
19
|
+
"lof": "LOF",
|
20
|
+
"ee": "EE",
|
21
|
+
"zscore": "zscore",
|
22
|
+
"rolling_zscore": "rolling_zscore",
|
23
|
+
"mad": "mad",
|
24
|
+
"minmax": "minmax",
|
25
|
+
"iqr": "IQR"
|
26
|
+
}
|
18
27
|
|
19
28
|
@runtime_dependency(
|
20
29
|
module="autots",
|
21
30
|
err_msg=(
|
22
|
-
|
23
|
-
|
31
|
+
"Please run `pip3 install autots` to "
|
32
|
+
"install the required dependencies for AutoTS."
|
24
33
|
),
|
25
34
|
)
|
26
35
|
def _build_model(self) -> AnomalyOutput:
|
27
36
|
from autots.evaluator.anomaly_detector import AnomalyDetector
|
28
37
|
|
29
|
-
method = self.spec.
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
self.spec.model_kwargs["transform_dict"] = transform_dict
|
44
|
-
|
45
|
-
if self.spec.contamination != 0.1: # TODO: remove hard-coding
|
46
|
-
self.spec.model_kwargs.get("method_params", {})[
|
47
|
-
"contamination"
|
48
|
-
] = self.spec.contamination
|
49
|
-
|
50
|
-
model = AnomalyDetector(**self.spec.model_kwargs)
|
38
|
+
method = SupportedModels.ISOLATIONFOREST if self.spec.model == SupportedModels.AutoTS else self.spec.model
|
39
|
+
model_params = {"method": self.model_mapping[method],
|
40
|
+
"transform_dict": self.spec.model_kwargs.get("transform_dict", {}),
|
41
|
+
"output": self.spec.model_kwargs.get("output", "univariate"), "method_params": {}}
|
42
|
+
# Supported methods with contamination param
|
43
|
+
if method in [SupportedModels.ISOLATIONFOREST, SupportedModels.LOF, SupportedModels.EE]:
|
44
|
+
model_params["method_params"][
|
45
|
+
"contamination"] = self.spec.contamination if self.spec.contamination else 0.01
|
46
|
+
else:
|
47
|
+
if self.spec.contamination:
|
48
|
+
raise ValueError(f"The contamination parameter is not supported for the selected model \"{method}\"")
|
49
|
+
logger.info(f"model params: {model_params}")
|
50
|
+
|
51
|
+
model = AnomalyDetector(**model_params)
|
51
52
|
|
52
53
|
date_column = self.spec.datetime_column.name
|
53
54
|
|
@@ -55,9 +56,7 @@ class AutoTSOperatorModel(AnomalyOperatorBaseModel):
|
|
55
56
|
|
56
57
|
for target, df in self.datasets.full_data_dict.items():
|
57
58
|
data = df.set_index(date_column)
|
58
|
-
|
59
59
|
(anomaly, score) = model.detect(data)
|
60
|
-
|
61
60
|
if len(anomaly.columns) == 1:
|
62
61
|
score.rename(
|
63
62
|
columns={score.columns.values[0]: OutputColumns.SCORE_COL},
|
@@ -65,19 +64,15 @@ class AutoTSOperatorModel(AnomalyOperatorBaseModel):
|
|
65
64
|
)
|
66
65
|
score = 1 - score
|
67
66
|
score = score.reset_index(drop=False)
|
68
|
-
|
69
67
|
col = anomaly.columns.values[0]
|
70
68
|
anomaly[col] = anomaly[col].replace({1: 0, -1: 1})
|
71
69
|
anomaly.rename(columns={col: OutputColumns.ANOMALY_COL}, inplace=True)
|
72
70
|
anomaly = anomaly.reset_index(drop=False)
|
73
|
-
|
74
71
|
anomaly_output.add_output(target, anomaly, score)
|
75
|
-
|
76
72
|
else:
|
77
73
|
raise NotImplementedError(
|
78
74
|
"Multi-Output Anomaly Detection is not yet supported in autots"
|
79
75
|
)
|
80
|
-
|
81
76
|
return anomaly_output
|
82
77
|
|
83
78
|
def _generate_report(self):
|
@@ -4,18 +4,14 @@
|
|
4
4
|
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
|
5
5
|
|
6
6
|
from ads.opctl.operator.lowcode.anomaly.utils import select_auto_model
|
7
|
-
|
8
|
-
from ..const import NonTimeADSupportedModels, SupportedModels
|
9
|
-
from ..operator_config import AnomalyOperatorConfig
|
10
7
|
from .anomaly_dataset import AnomalyDatasets
|
11
|
-
from .automlx import AutoMLXOperatorModel
|
12
8
|
from .autots import AutoTSOperatorModel
|
13
|
-
|
14
|
-
# from .tods import TODSOperatorModel
|
15
9
|
from .base_model import AnomalyOperatorBaseModel
|
16
10
|
from .isolationforest import IsolationForestOperatorModel
|
17
11
|
from .oneclasssvm import OneClassSVMOperatorModel
|
18
12
|
from .randomcutforest import RandomCutForestOperatorModel
|
13
|
+
from ..const import NonTimeADSupportedModels, SupportedModels
|
14
|
+
from ..operator_config import AnomalyOperatorConfig
|
19
15
|
|
20
16
|
|
21
17
|
class UnSupportedModelError(Exception):
|
@@ -45,9 +41,14 @@ class AnomalyOperatorModelFactory:
|
|
45
41
|
"""
|
46
42
|
|
47
43
|
_MAP = {
|
48
|
-
SupportedModels.AutoMLX: AutoMLXOperatorModel,
|
49
|
-
# SupportedModels.TODS: TODSOperatorModel,
|
50
44
|
SupportedModels.AutoTS: AutoTSOperatorModel,
|
45
|
+
SupportedModels.IQR: AutoTSOperatorModel,
|
46
|
+
SupportedModels.LOF: AutoTSOperatorModel,
|
47
|
+
SupportedModels.ISOLATIONFOREST: AutoTSOperatorModel,
|
48
|
+
SupportedModels.ZSCORE: AutoTSOperatorModel,
|
49
|
+
SupportedModels.ROLLING_ZSCORE: AutoTSOperatorModel,
|
50
|
+
SupportedModels.EE: AutoTSOperatorModel,
|
51
|
+
SupportedModels.MAD: AutoTSOperatorModel
|
51
52
|
}
|
52
53
|
|
53
54
|
_NonTime_MAP = {
|
@@ -364,15 +364,21 @@ spec:
|
|
364
364
|
- oneclasssvm
|
365
365
|
- isolationforest
|
366
366
|
- randomcutforest
|
367
|
+
- iqr
|
368
|
+
- lof
|
369
|
+
- zscore
|
370
|
+
- rolling_zscore
|
371
|
+
- mad
|
372
|
+
- ee
|
367
373
|
meta:
|
368
374
|
description: "The model to be used for anomaly detection"
|
369
375
|
|
370
376
|
contamination:
|
371
377
|
required: false
|
372
|
-
default: 0.
|
378
|
+
default: 0.01
|
373
379
|
type: float
|
374
380
|
meta:
|
375
|
-
description: "
|
381
|
+
description: "The proportion of outliers in the data set. The contamination should be in the range (0, 0.5]"
|
376
382
|
|
377
383
|
model_kwargs:
|
378
384
|
type: dict
|
@@ -2,12 +2,12 @@ type: forecast
|
|
2
2
|
version: v1
|
3
3
|
name: Forecasting Operator
|
4
4
|
conda_type: service
|
5
|
-
conda:
|
5
|
+
conda: forecast_p310_cpu_x86_64_v4
|
6
6
|
gpu: no
|
7
7
|
jobs_default_params:
|
8
8
|
shape_name: VM.Standard.E4.Flex
|
9
|
-
ocpus:
|
10
|
-
memory_in_gbs:
|
9
|
+
ocpus: 16
|
10
|
+
memory_in_gbs: 256
|
11
11
|
block_storage_size_in_GBs: 512
|
12
12
|
keywords:
|
13
13
|
- Prophet
|
@@ -49,7 +49,7 @@ class AutoMLXOperatorModel(ForecastOperatorBaseModel):
|
|
49
49
|
time_budget = model_kwargs_cleaned.pop("time_budget", -1)
|
50
50
|
model_kwargs_cleaned[
|
51
51
|
"preprocessing"
|
52
|
-
] = self.spec.preprocessing or model_kwargs_cleaned.get("preprocessing", True)
|
52
|
+
] = self.spec.preprocessing.enabled or model_kwargs_cleaned.get("preprocessing", True)
|
53
53
|
return model_kwargs_cleaned, time_budget
|
54
54
|
|
55
55
|
def preprocess(self, data, series_id=None): # TODO: re-use self.le for explanations
|
@@ -68,7 +68,7 @@ class AdditionalData(AbstractData):
|
|
68
68
|
add_dates.sort()
|
69
69
|
if historical_data.get_max_time() > add_dates[-spec.horizon]:
|
70
70
|
raise DataMismatchError(
|
71
|
-
f"The Historical Data ends on {historical_data.get_max_time()}. The additional data horizon starts on {add_dates[-spec.horizon]}. The horizon should have exactly {spec.horizon} dates after the
|
71
|
+
f"The Historical Data ends on {historical_data.get_max_time()}. The additional data horizon starts on {add_dates[-spec.horizon]}. The horizon should have exactly {spec.horizon} dates after the Historical at a frequency of {historical_data.freq}"
|
72
72
|
)
|
73
73
|
elif historical_data.get_max_time() != add_dates[-(spec.horizon + 1)]:
|
74
74
|
raise DataMismatchError(
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: oracle_ads
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.12.1
|
4
4
|
Summary: Oracle Accelerated Data Science SDK
|
5
5
|
Keywords: Oracle Cloud Infrastructure,OCI,Machine Learning,ML,Artificial Intelligence,AI,Data Science,Cloud,Oracle
|
6
6
|
Author: Oracle Data Science
|
@@ -82,8 +82,10 @@ Requires-Dist: fiona<=1.9.6 ; extra == "geo"
|
|
82
82
|
Requires-Dist: oracle_ads[viz] ; extra == "geo"
|
83
83
|
Requires-Dist: transformers ; extra == "huggingface"
|
84
84
|
Requires-Dist: tf-keras ; extra == "huggingface"
|
85
|
-
Requires-Dist: langchain
|
86
|
-
Requires-Dist: langchain
|
85
|
+
Requires-Dist: langchain>=0.2 ; extra == "llm"
|
86
|
+
Requires-Dist: langchain-community ; extra == "llm"
|
87
|
+
Requires-Dist: langchain_openai ; extra == "llm"
|
88
|
+
Requires-Dist: pydantic>=2,<3 ; extra == "llm"
|
87
89
|
Requires-Dist: evaluate>=0.4.0 ; extra == "llm"
|
88
90
|
Requires-Dist: ipython>=7.23.1, <8.0 ; extra == "notebook"
|
89
91
|
Requires-Dist: ipywidgets~=7.6.3 ; extra == "notebook"
|
@@ -145,7 +147,7 @@ Requires-Dist: statsmodels>=0.14.1 ; extra == "testsuite" and ( python_version>=
|
|
145
147
|
Requires-Dist: tables ; extra == "testsuite"
|
146
148
|
Requires-Dist: tables>3.9.0 ; extra == "testsuite" and ( python_version>='3.9')
|
147
149
|
Requires-Dist: xlrd>=1.2.0 ; extra == "testsuite"
|
148
|
-
Requires-Dist: spacy>=3.4.2 ; extra == "text"
|
150
|
+
Requires-Dist: spacy>=3.4.2,<3.8 ; extra == "text"
|
149
151
|
Requires-Dist: wordcloud>=1.8.1 ; extra == "text"
|
150
152
|
Requires-Dist: oracle_ads[viz] ; extra == "torch"
|
151
153
|
Requires-Dist: torch ; extra == "torch"
|