Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions THIRD_PARTY_LICENSES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ asteval
* Source code: https://github.com/newville/asteval
* Project home: https://github.com/newville/asteval

autots
* Copyright (c) 2024 Colin Catlin
* License: MIT License
* Source code: https://github.com/winedarksea/AutoTS
* Project home: https://winedarksea.github.io/AutoTS/build/html/index.html

bokeh
* Copyright Copyright (c) 2012 - 2021, Anaconda, Inc., and Bokeh Contributors
* License: BSD 3-Clause "New" or "Revised" License
Expand Down Expand Up @@ -169,6 +175,12 @@ nbformat
* Source code: https://github.com/jupyter/nbconvert
* Project home: https://jupyter.org/

neuralprophet
* Copyright (c) 2020 Oskar Triebe
* License: MIT License
* Source Code: https://github.com/ourownstory/neural_prophet
* Project Home: https://neuralprophet.com

numpy
* Copyright (c) 2005-2021, NumPy Developers.
* License: BSD 3-Clause "New" or "Revised" License
Expand Down Expand Up @@ -247,6 +259,18 @@ plotly
* Source code: https://github.com/plotly/plotly.py
* Project home: https://plotly.com/

pmdarima
* Copyright (c) 2017 Taylor G Smith
* License: MIT License
* Source code: https://github.com/alkaline-ml/pmdarima
* Project home: https://alkaline-ml.com/pmdarima/

prophet
* Copyright (c) Facebook, Inc. and its affiliates.
* License: MIT License
* Source code: https://github.com/facebook/prophet
* Project home: https://facebook.github.io/prophet/

protobuf
* Copyright 2008 Google Inc. All rights reserved.
* License: Google Protobuf License
Expand Down Expand Up @@ -289,6 +313,12 @@ PyYAML
* Source code: https://github.com/yaml/pyyaml/
* Project home: https://pyyaml.org/

report-creator
* Copyright 2024 Daren Race
* License: MIT License
* Source code: https://github.com/darenr/report_creator
* Project home: https://darenr.github.io/report_creator/

requests
* Copyright 2023 Kenneth Reitz
* License: Apache-2.0 license
Expand Down
8 changes: 7 additions & 1 deletion ads/llm/serializers/runnable_parallel.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*--

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

from langchain.schema.runnable import RunnableParallel
from langchain.load.dump import dumpd
from langchain.load.load import load
Expand All @@ -10,7 +16,7 @@ def type():

@staticmethod
def load(config: dict, **kwargs):
steps = config["kwargs"]["steps"]
steps = config.get("kwargs", dict()).get("steps", dict())
steps = {k: load(v, **kwargs) for k, v in steps.items()}
return RunnableParallel(**steps)

Expand Down
2 changes: 1 addition & 1 deletion ads/opctl/operator/lowcode/anomaly/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ All generated configurations should be ready to use without the need for any add
To run anomaly detection locally, create and activate a new conda environment (`ads-anomaly`). Install all the required libraries listed in the `environment.yaml` file.

```yaml
- datapane
- report-creator
- cerberus
- oracle-automlx==23.4.1
- oracle-automlx[classic]==23.4.1
Expand Down
2 changes: 1 addition & 1 deletion ads/opctl/operator/lowcode/anomaly/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dependencies:
- python=3.8
- pip
- pip:
- datapane
- report-creator
- cerberus
- oracle-automlx==23.4.1
- oracle-automlx[classic]==23.4.1
Expand Down
25 changes: 15 additions & 10 deletions ads/opctl/operator/lowcode/anomaly/model/automlx.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*--

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

import pandas as pd
Expand All @@ -27,8 +27,13 @@ class AutoMLXOperatorModel(AnomalyOperatorBaseModel):
def _build_model(self) -> pd.DataFrame:
from automlx import init
import logging

try:
init(engine="ray", engine_opts={"ray_setup": {"_temp_dir": "/tmp/ray-temp"}}, loglevel=logging.CRITICAL)
init(
engine="ray",
engine_opts={"ray_setup": {"_temp_dir": "/tmp/ray-temp"}},
loglevel=logging.CRITICAL,
)
except Exception as e:
logger.info("Ray already initialized")
date_column = self.spec.datetime_column.name
Expand Down Expand Up @@ -68,21 +73,21 @@ def _build_model(self) -> pd.DataFrame:
return anomaly_output

def _generate_report(self):
import datapane as dp
import report_creator as rc

"""The method that needs to be implemented on the particular model level."""
selected_models_text = dp.Text(
f"## Selected Models Overview \n "
"The following tables provide information regarding the chosen model."
)
all_sections = [selected_models_text]
other_sections = [
rc.Heading("Selected Models Overview", level=2),
rc.Text(
"The following tables provide information regarding the chosen model."
),
]

model_description = dp.Text(
model_description = rc.Text(
"The automlx model automatically pre-processes, selects and engineers "
"high-quality features in your dataset, which then given to an automatically "
"chosen and optimized machine learning model.."
)
other_sections = all_sections

return (
model_description,
Expand Down
19 changes: 9 additions & 10 deletions ads/opctl/operator/lowcode/anomaly/model/autots.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*--

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

import pandas as pd
Expand Down Expand Up @@ -81,21 +81,20 @@ def _build_model(self) -> AnomalyOutput:
return anomaly_output

def _generate_report(self):
import datapane as dp
import report_creator as rc

"""The method that needs to be implemented on the particular model level."""
selected_models_text = dp.Text(
f"## Selected Models Overview \n "
"The following tables provide information regarding the chosen model."
)
all_sections = [selected_models_text]

model_description = dp.Text(
other_sections = [
rc.Heading("Selected Models Overview", level=2),
rc.Text(
"The following tables provide information regarding the chosen model."
),
]
model_description = rc.Text(
"The automlx model automatically pre-processes, selects and engineers "
"high-quality features in your dataset, which then given to an automatically "
"chosen and optimized machine learning model.."
)
other_sections = all_sections

return (
model_description,
Expand Down
71 changes: 34 additions & 37 deletions ads/opctl/operator/lowcode/anomaly/model/base_model.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*--

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

import os
Expand Down Expand Up @@ -57,7 +57,7 @@ def __init__(self, config: AnomalyOperatorConfig, datasets: AnomalyDatasets):

def generate_report(self):
"""Generates the report."""
import datapane as dp
import report_creator as rc
import matplotlib.pyplot as plt

start_time = time.time()
Expand All @@ -79,12 +79,10 @@ def generate_report(self):
anomaly_output, test_data, elapsed_time
)
table_blocks = [
dp.DataTable(df, label=col)
rc.DataTable(df, label=col, index=True)
for col, df in self.datasets.full_data_dict.items()
]
data_table = (
dp.Select(blocks=table_blocks) if len(table_blocks) > 1 else table_blocks[0]
)
data_table = rc.Select(blocks=table_blocks)
date_column = self.spec.datetime_column.name

blocks = []
Expand All @@ -106,44 +104,42 @@ def generate_report(self):
plt.xlabel(date_column)
plt.ylabel(col)
plt.title(f"`{col}` with reference to anomalies")
figure_blocks.append(ax)
blocks.append(dp.Group(blocks=figure_blocks, label=target))
plots = dp.Select(blocks=blocks) if len(blocks) > 1 else blocks[0]
figure_blocks.append(rc.Widget(ax))
blocks.append(rc.Group(*figure_blocks, label=target))
plots = rc.Select(blocks)

report_sections = []
title_text = dp.Text("# Anomaly Detection Report")

yaml_appendix_title = dp.Text(f"## Reference: YAML File")
yaml_appendix = dp.Code(code=self.config.to_yaml(), language="yaml")
summary = dp.Blocks(
blocks=[
dp.Group(
dp.Text(f"You selected the **`{self.spec.model}`** model."),
dp.Text(
"Based on your dataset, you could have also selected "
f"any of the models: `{'`, `'.join(SupportedModels.keys())}`."
),
dp.BigNumber(
heading="Analysis was completed in ",
value=human_time_friendly(elapsed_time),
),
label="Summary",
)
]
title_text = rc.Heading("Anomaly Detection Report", level=1)

yaml_appendix_title = rc.Heading("Reference: YAML File", level=2)
yaml_appendix = rc.Yaml(self.config.to_dict())
summary = rc.Block(
rc.Group(
rc.Text(f"You selected the **`{self.spec.model}`** model."),
rc.Text(
"Based on your dataset, you could have also selected "
f"any of the models: `{'`, `'.join(SupportedModels.keys())}`."
),
rc.Metric(
heading="Analysis was completed in ",
value=human_time_friendly(elapsed_time),
),
label="Summary",
)
)
sec_text = dp.Text(f"## Train Evaluation Metrics")
sec = dp.DataTable(self._evaluation_metrics(anomaly_output))
sec_text = rc.Heading("Train Evaluation Metrics", level=2)
sec = rc.DataTable(self._evaluation_metrics(anomaly_output), index=True)
evaluation_metrics_sec = [sec_text, sec]

test_metrics_sections = []
if total_metrics is not None and not total_metrics.empty:
sec_text = dp.Text(f"## Test Data Evaluation Metrics")
sec = dp.DataTable(total_metrics)
sec_text = rc.Heading("Test Data Evaluation Metrics", level=2)
sec = rc.DataTable(total_metrics, index=True)
test_metrics_sections = test_metrics_sections + [sec_text, sec]

if summary_metrics is not None and not summary_metrics.empty:
sec_text = dp.Text(f"## Test Data Summary Metrics")
sec = dp.DataTable(summary_metrics)
sec_text = rc.Heading("Test Data Summary Metrics", level=2)
sec = rc.DataTable(summary_metrics, index=True)
test_metrics_sections = test_metrics_sections + [sec_text, sec]

report_sections = (
Expand Down Expand Up @@ -248,7 +244,7 @@ def _save_report(
test_metrics: pd.DataFrame,
):
"""Saves resulting reports to the given folder."""
import datapane as dp
import report_creator as rc

unique_output_dir = find_output_dirname(self.spec.output_directory)

Expand All @@ -257,11 +253,12 @@ def _save_report(
else:
storage_options = dict()

# datapane html report
# report-creator html report
with tempfile.TemporaryDirectory() as temp_dir:
report_local_path = os.path.join(temp_dir, "___report.html")
disable_print()
dp.save_report(report_sections, report_local_path)
with rc.ReportCreator("My Report") as report:
report.save(rc.Block(*report_sections), report_local_path)
enable_print()
with open(report_local_path) as f1:
with fsspec.open(
Expand Down
8 changes: 4 additions & 4 deletions ads/opctl/operator/lowcode/anomaly/model/tods.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# #!/usr/bin/env python
# # -*- coding: utf-8 -*--

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

# import importlib
Expand Down Expand Up @@ -97,16 +97,16 @@
# return anomaly_output

# def _generate_report(self):
# import datapane as dp
# import report_creator as rc

# """The method that needs to be implemented on the particular model level."""
# selected_models_text = dp.Text(
# selected_models_text = rc.Text(
# f"## Selected Models Overview \n "
# "The following tables provide information regarding the chosen model."
# )
# all_sections = [selected_models_text]

# model_description = dp.Text(
# model_description = rc.Text(
# "The tods model is a full-stack automated machine learning system for outlier detection "
# "on univariate / multivariate time-series data. It provides exhaustive modules for building "
# "machine learning-based outlier detection systems and wide range of algorithms."
Expand Down
2 changes: 1 addition & 1 deletion ads/opctl/operator/lowcode/anomaly/schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ spec:
missing_value_imputation:
type: boolean
required: false
default: true
default: false

generate_report:
type: boolean
Expand Down
2 changes: 1 addition & 1 deletion ads/opctl/operator/lowcode/forecast/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ To run forecasting locally, create and activate a new conda environment (`ads-fo
- neuralprophet
- pmdarima
- statsmodels
- datapane
- report-creator
- cerberus
- sktime
- optuna==3.1.0
Expand Down
8 changes: 4 additions & 4 deletions ads/opctl/operator/lowcode/forecast/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ dependencies:
- neuralprophet
- pmdarima
- statsmodels
- datapane
- report-creator
- cerberus
- sktime
- shap
- autots[additional]
- optuna==3.1.0
- oracle-automlx==23.4.1
- oracle-automlx[forecasting]==23.4.1
- optuna
- oracle-automlx>=23.4.1
- oracle-automlx[forecasting]>=23.4.1
- fire
Loading