### Quick Start for Recommender Operator
Source: https://accelerated-data-science.readthedocs.io/en/latest/_modules/ads/common/data
A brief guide to getting started with the Recommender Operator. It would explain the basic setup and execution for generating recommendations. The source text lacks specific code or configuration examples.
```yaml
# Example YAML configuration for Recommender Operator (details omitted)
# operator: recommender
# version: "1.0"
# inputs:
# user_item_data: "oci://.../interactions.csv"
# user_id_col: "user_id"
# item_id_col: "item_id"
# output:
# recommendations: "oci://.../recommendations.csv"
```
--------------------------------
### Quick Start for AI Forecast Operator
Source: https://accelerated-data-science.readthedocs.io/en/latest/_modules/ads/common/data
This is likely a brief guide to get started with the AI Forecast Operator. It would cover the minimum steps required to set up and run a basic forecasting task. The actual code or configuration examples are not present in the provided text.
```yaml
# Example YAML configuration structure for AI Forecast Operator (details omitted)
# operator: ai_forecast
# version: "1.0"
# inputs:
# time_series_data: "oci://.../data.csv"
# target_column: "sales"
# forecast_horizon: 30
# output:
# forecast_data: "oci://.../forecasts.csv"
```
--------------------------------
### Example core-site.xml for Resource Principals
Source: https://accelerated-data-science.readthedocs.io/en/latest/_sources/user_guide/apachespark/setup-installation
An example XML configuration for core-site.xml demonstrating how to set up authentication for OCI Object Storage using resource principals. It specifies the Object Storage hostname and the custom authenticator class.
```xml
fs.oci.client.hostname
https://objectstorage.us-ashburn-1.oraclecloud.com
fs.oci.client.custom.authenticator
com.oracle.bmc.hdfs.auth.ResourcePrincipalsCustomAuthenticator
```
--------------------------------
### Apache Spark Quick Start
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/operators/common/run
A quick start guide for using Apache Spark with ADS. This section likely covers basic setup and running simple Spark applications.
```python
from pyspark.sql import SparkSession
# Create a SparkSession
spark = SparkSession.builder \
.appName("ADSSparkQuickStart") \
.getOrCreate()
# Example: Create a simple DataFrame
data = [("Alice", 1), ("Bob", 2)]
columns = ["name", "id"]
df = spark.createDataFrame(data, columns)
df.show()
# Stop the SparkSession
spark.stop()
```
--------------------------------
### Quick Start for Recommender Operator (Python)
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/secrets/quick_start
A quick start guide for the Recommender Operator. This section likely provides simple code examples to demonstrate how to set up and run a basic recommendation engine using the operator.
```python
# Example quick start for Recommender Operator
# from ads.opctl.operator.factory import OperatorFactory
#
# recommender = OperatorFactory.create_operator(
# operator_name='recommender',
# dataset=user_item_interactions,
# target_column='user_id'
# )
# recommender.execute()
# print(recommender.get_artifact('recommendations'))
```
--------------------------------
### Quick Start for Apache Spark Integration - Python
Source: https://accelerated-data-science.readthedocs.io/en/latest/_modules/ads/feature_engineering/feature_type/document
Provides a basic example of how to get started with Apache Spark integration within the ADS framework. This typically involves setting up a Spark environment and performing basic Spark operations. Assumes Spark and ADS are installed and configured.
```python
from pyspark.sql import SparkSession
# Create a SparkSession
spark = SparkSession.builder \
.appName("ADS Spark Quick Start") \
.getOrCreate()
# Example: Create a simple DataFrame
data = [("Alice", 1), ("Bob", 2)]
columns = ["name", "id"]
df = spark.createDataFrame(data, columns)
# Show the DataFrame
df.show()
# Perform a Spark action (e.g., count)
print(f"Number of rows: {df.count()}")
# Stop the SparkSession
spark.stop()
```
--------------------------------
### Apache Spark Quick Start
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/big_data_service/connect
Provides a quick start guide for using Apache Spark with ADS. This section likely covers basic setup and running simple Spark applications on OCI. Assumes Spark is installed and configured.
```python
from pyspark.sql import SparkSession
# Create a Spark session
spark = SparkSession.builder \
.appName("ADS Spark Quick Start") \
.getOrCreate()
# Example: Create a simple DataFrame
data = [("Alice", 1), ("Bob", 2)]
columns = ["name", "id"]
df = spark.createDataFrame(data, columns)
df.show()
# Stop the Spark session
spark.stop()
```
--------------------------------
### Getting Started with the PII Operator
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/jobs/policies
A quick start guide for the PII Operator, covering the initial steps to set it up and perform basic PII detection tasks.
```python
from ads.dataset import ADSDataset
from ads.opctl.operator.lowcode.pii.operator import PIIOperator
# Load your dataset
data = ADSDataset(path="./sensitive_data.csv", type="csv")
# Define operator configuration
operator_config = {
"type": "PII",
"name": "my-pii-scanner",
"inputs": {"data": data},
"outputs": {"data": None},
"parameters": {
"entity_types": ["EMAIL", "PHONE_NUMBER"],
"confidence_threshold": 0.8
}
}
# Instantiate and run the operator
pii_op = PIIOperator(operator_config)
pii_op.execute()
# Get the results with detected PII
pii_results = pii_op.get_outputs()["data"]
print(pii_results.head())
```
--------------------------------
### Apache Spark Quick Start and Setup
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/large_language_model/index
Provides a quick start guide and setup instructions for integrating Apache Spark with ADS. This covers initial setup, configuration, and running Spark applications on OCI Data Flow. It's essential for users working with large datasets that benefit from distributed processing.
```python
# Conceptual example for Apache Spark Quick Start
# This would typically involve setting up Spark environment and submitting jobs
# Example: Submitting a Spark job to OCI Data Flow using ADS CLI or SDK
# from ads.jobs import SparkJob
# job = SparkJob(
# script_uri='oci://bucket@namespace/path/to/your/spark_script.py',
# archive_uri='oci://bucket@namespace/path/to/your/dependencies.zip',
# driver_shape='OC3',
# executor_shape='OC3',
# num_executors=1,
# conf={'spark.yarn.archive': 'oci://bucket@namespace/path/to/spark_archive.zip'}
# )
# run = job.run()
print("This snippet represents conceptual calls for Apache Spark integration with ADS.")
print("Actual implementation depends on the ADS job submission API for Spark.")
```
--------------------------------
### Quick Start for Apache Spark
Source: https://accelerated-data-science.readthedocs.io/en/latest/_modules/ads/dataset/forecasting_dataset
This section provides a quick start guide for using Apache Spark within the ADS framework. It covers the essential steps to get started with Spark applications, including setup and basic usage.
```python
from ads.spark import SparkSession
# Create a SparkSession
session = SparkSession.builder.appName("ADSSparkQuickStart").getOrCreate()
# Example Spark operation
data = [("Alice", 1), ("Bob", 2)]
schema = ["name", "id"]
rdd = session.sparkContext.parallelize(data)
df = session.createDataFrame(rdd, schema)
df.show()
session.stop()
```
--------------------------------
### Apache Spark Quick Start in Python
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/loading_data/connect_legacy
A basic example demonstrating how to get started with Apache Spark using the ADS library in Python. This snippet focuses on initializing a Spark session and performing a simple operation. Ensure Spark and necessary OCI connectors are installed and configured.
```python
from pyspark.sql import SparkSession
# Create a SparkSession
spark = SparkSession.builder \
.appName("ADS Spark Quick Start") \
.getOrCreate()
# Example: Create a simple DataFrame
data = [("Alice", 1), ("Bob", 2)]
columns = ["name", "id"]
df = spark.createDataFrame(data, columns)
# Show the DataFrame
df.show()
# Stop the SparkSession
spark.stop()
print("Spark Quick Start complete.")
```
--------------------------------
### Apache Spark Quick Start and Setup in Python
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/cli/quickstart
Provides a quick start guide and setup instructions for using Apache Spark with ADS. This involves configuring the environment and running Spark applications, particularly on OCI Data Flow. Requires Spark and potentially OCI Data Flow configuration.
```python
from ads.spark.generic_spark_runner import GenericSparkRunner
# Example: Running a simple Spark job locally (requires Spark installation)
# In a real OCI Data Flow scenario, you would configure this differently.
# Define your Spark application code (e.g., in a separate file or as a string)
sample_spark_code = """
from pyspark.sql import SparkSession
spark = SparkSession.builder.appName("SimpleSparkApp").getOrCreate()
data = [("Alice", 1), ("Bob", 2)]
columns = ["name", "id"]
df = spark.createDataFrame(data, columns)
df.show()
spark.stop()
"""
# Create a Spark runner instance
# For OCI Data Flow, you'd typically use SparkJobBuilder instead
spark_runner = GenericSparkRunner()
# Submit and run the Spark job
# This example assumes Spark is configured locally.
# For OCI Data Flow, you would use job submission APIs.
try:
spark_runner.run_string(sample_spark_code)
print("Spark job executed successfully.")
except Exception as e:
print(f"Error running Spark job: {e}")
# For OCI Data Flow, a typical job submission would look like:
# from ads.spark.spark_job_builder import SparkJobBuilder
#
# job = SparkJobBuilder()
# job.with_application_file('path/to/your/spark_app.py')
# job.with_infrastructure(shape_name='medium', num_executors=1, etc...)
# job.create(compartment_id='your_compartment_id', project_id='your_project_id')
# job.run()
```
--------------------------------
### Data Catalog Metastore Quick Start
Source: https://accelerated-data-science.readthedocs.io/en/latest/_modules/ads/common/ipython
This guide provides a quick start for using the Data Catalog Metastore with ADS. It likely covers the initial setup and basic operations for cataloging and discovering data assets.
```bash
# Example: Registering a data source (conceptual)
# This would typically involve using the OCI Data Catalog UI or API.
#
# Example: Connecting Spark to the Metastore (using spark-defaults.conf)
# In spark-defaults.conf or SparkConf:
# spark.hadoop.hive.metastore.uris thrift://your-metastore-host:9083
# spark.sql.catalog.spark_catalog.type hive
# spark.sql.catalog.spark_catalog.hive.metastore.uris thrift://your-metastore-host:9083
# spark.sql.catalog.spark_catalog.default.database default
# Example: Reading data from a metastore table using Spark SQL
# spark.sql("SELECT * FROM my_catalog.my_schema.my_table").show()
```
--------------------------------
### Data Catalog Metastore: Quick Start
Source: https://accelerated-data-science.readthedocs.io/en/latest/ads.feature_engineering.adsstring
A quick start guide for using the Data Catalog Metastore, likely within the context of Apache Spark on OCI. This section focuses on the initial steps to get the metastore operational.
```python
# Example: Configuring Spark to use OCI Data Catalog Metastore
from pyspark.sql import SparkSession
spark = SparkSession.builder \
.appName("DataCatalogMetastoreExample") \
.config("spark.sql.catalog.ocidsc", "com.oracle.oci.common.spark.OciSparkCatalog") \
.config("spark.hadoop.fs.oci.client.config.location", "/etc/oci/config") \
.getOrCreate()
# Now you can interact with tables registered in OCI Data Catalog
df = spark.sql("SELECT * FROM ocidsc.your_catalog_name.your_schema_name.your_table_name LIMIT 10")
df.show()
```
--------------------------------
### Quick Start for AI Forecast Operator (Python)
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/secrets/quick_start
A concise guide to getting started with the AI Forecast Operator. This typically involves minimal code examples to demonstrate basic usage, data input, and obtaining forecasts.
```python
# Example quick start for Forecast Operator
# from ads.opctl.operator.factory import OperatorFactory
#
# forecast_operator = OperatorFactory.create_operator(
# operator_name='forecast',
# dataset=my_dataset,
# target_column='sales'
# )
# forecast_operator.execute()
# print(forecast_operator.get_artifact('forecast_result'))
```
--------------------------------
### ADSTuner Quick Start
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/operators/common/run
A quick start guide for using ADSTuner, a component likely used for hyperparameter tuning in ADS. This section covers basic usage and setup.
```python
from ads.tuning.tuner import ADSTuner
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
from sklearn.datasets import make_classification
# Generate some sample data
X, y = make_classification(n_samples=1000, n_features=10, random_state=42)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Define the model
estimator = RandomForestClassifier(random_state=42)
# Define the hyperparameter search space
search_space = {
'n_estimators': [50, 100, 200],
'max_depth': [None, 10, 20]
}
# Initialize ADSTuner
tuner = ADSTuner(estimator=estimator,
search_space=search_space,
max_trials=10,
scoring='accuracy')
# Run the tuning process
tuner.fit(X_train, y_train)
# Get the best estimator
best_model = tuner.best_estimator_
print(f"Best parameters found: {tuner.best_params_}")
# Evaluate the best model
accuracy = best_model.score(X_test, y_test)
print(f"Accuracy with best model: {accuracy}")
```
--------------------------------
### Install ADS with Optuna Module
Source: https://accelerated-data-science.readthedocs.io/en/latest/_sources/user_guide/cli/quickstart
Installs the `oracle-ads` package with the `optuna` extra libraries for hyperparameter optimization tasks. This module includes the `optuna` library and libraries from the `viz` module.
```bash
python3 -m pip install "oracle-ads[optuna]"
```
--------------------------------
### Quick Start for Apache Spark
Source: https://accelerated-data-science.readthedocs.io/en/latest/_modules/ads/common/decorator/runtime_dependency
Provides a rapid introduction to using Apache Spark within the ADS environment. This section covers the essential steps to get started with Spark, including setup and basic operations for data processing.
```python
from pyspark.sql import SparkSession
# Create a SparkSession
spark = SparkSession.builder \
.appName("ADS Spark Quick Start") \
.getOrCreate()
# Example: Create a simple DataFrame
data = [("Alice", 1), ("Bob", 2)]
columns = ["Name", "ID"]
df = spark.createDataFrame(data, columns)
df.show()
# Example: Read data from a source (e.g., CSV)
# try:
# csv_path = "oci://your-bucket@your-namespace/path/to/your/data.csv"
# df_csv = spark.read.csv(csv_path, header=True, inferSchema=True)
# df_csv.show()
# except Exception as e:
# print(f"Error reading CSV: {e}")
# Stop the SparkSession
spark.stop()
```
--------------------------------
### Python - Apache Spark Quick Start
Source: https://accelerated-data-science.readthedocs.io/en/latest/_modules/ads/data_labeling/visualizer/image_visualizer
Provides a quick start guide for using Apache Spark with ADS. Covers basic setup and running Spark applications on OCI Data Flow.
```python
# Example of initializing Spark session (conceptual)
# from pyspark.sql import SparkSession
# spark = SparkSession.builder.appName("ADSSparkExample").getOrCreate()
# Code for Spark operations would follow.
# This might involve reading data, transformations, and model training using Spark MLlib.
```
--------------------------------
### Python: Apache Spark Quick Start
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/model_serialization/pytorchmodel
Provides a basic introduction and quick start guide for using Apache Spark, likely within the context of OCI Data Science or related services. This covers initial setup and a simple Spark job example. Requires Apache Spark environment and a compatible language environment (e.g., Python with PySpark).
```python
# This is a conceptual PySpark example.
# Assumes SparkSession is available (e.g., in a Zeppelin notebook on OCI or via Data Flow).
from pyspark.sql import SparkSession
# Create a SparkSession
sparksession = SparkSession.builder \
.appName("SparkQuickStart") \
.getOrCreate()
# Create a simple DataFrame
data = [("Alice", 1), ("Bob", 2), ("Charlie", 3)]
columns = ["name", "id"]
df = sparksession.createDataFrame(data, columns)
# Show the DataFrame
df.show()
# Perform a simple transformation
filtered_df = df.filter(df.id > 1)
filtered_df.show()
# Stop the SparkSession
sparksession.stop()
print("Apache Spark Quick Start example complete.")
```
--------------------------------
### Data Catalog Metastore Quick Start
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/model_registration/frameworks/xgboostmodel
This section provides a quick start guide for using the Data Catalog Metastore with ADS. It outlines the initial steps required to connect to and utilize the metastore for managing data assets and metadata. The code examples focus on basic connection and querying.
```python
from ads.catalog.metastore import Metastore
# Example of connecting to the Data Catalog Metastore
metastore = Metastore()
metastore.connect()
# Example of listing tables
tables = metastore.list_tables()
print(tables)
```
--------------------------------
### Quick Start Data Catalog Metastore
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/cli/opctl/_template/jobs
This quick start guide provides a basic example of connecting to and utilizing the Data Catalog Metastore with ADS and Apache Spark for data discovery and access.
```python
from pyspark.sql import SparkSession
spark = SparkSession.builder \
.appName("DataCatalogMetastoreExample") \
.config("spark.sql.catalog.spark_catalog", "org.apache.hadoop.hive.ql.io.s3a.S3AFileSystem") \
.config("spark.hadoop.fs.oci.impl", "com.oracle.bmc.hdfs.BmcProvider") \
.config("spark.hadoop.fs.s3a.impl", "com.oracle.bmc.hdfs.BmcProvider") \
.config("spark.dataintegration.metastore.catalog.type", "oci") \
.getOrCreate()
# Example: Reading data from a table registered in Data Catalog
df = spark.sql("SELECT * FROM your_catalog.your_schema.your_table")
df.show()
spark.stop()
```
--------------------------------
### Install ADS with Multiple Optional Modules
Source: https://accelerated-data-science.readthedocs.io/en/latest/_sources/user_guide/cli/quickstart
Installs the `oracle-ads` package with multiple optional modules simultaneously. This allows for customized installations based on specific project requirements, combining functionalities from different modules.
```bash
python3 -m pip install "oracle-ads[notebook,viz,text]"
```
--------------------------------
### AI Forecast Operator Quick Start
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/jobs/policies
A concise guide to getting started with the AI Forecast Operator. It covers the basic steps needed to set up and run a forecasting task using the operator.
```yaml
type: "Forecast"
name: "my-first-forecast"
inputs:
data: "{{ 0 | ads_model }}"
outputs:
forecast: "{{ 1 | ads_model }}"
parameters:
time_column: "ds"
target_column: "y"
horizon: 7
freq: "D"
```
--------------------------------
### Data Catalog Metastore Quick Start
Source: https://accelerated-data-science.readthedocs.io/en/latest/_modules/ads/model/runtime/model_deployment_details
This snippet provides a quick start guide for using the Data Catalog Metastore within ADS. It focuses on the initial setup and basic usage for cataloging data assets. The code likely involves connecting
--------------------------------
### Data Science Pipelines Quick Start
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/big_data_service/connect
A quick start guide for creating and running data science pipelines using ADS. This section likely covers defining pipeline steps and executing them. Requires ADS SDK setup.
```python
from ads.pipeline import Pipeline, PipelineStep
# Define pipeline steps
step1 = PipelineStep(
name="Step 1: Load Data",
script="scripts/load_data.py",
arguments={'input_path': 'data/raw/'}
)
step2 = PipelineStep(
name="Step 2: Train Model",
script="scripts/train_model.py",
arguments={'data_path': 'data/processed/', 'model_output': 'models/'}
)
# Create a pipeline
pipeline = Pipeline(
"My First Pipeline",
steps=[step1, step2],
project_id="your_project_id"
)
# Run the pipeline
# pipeline_run = pipeline.run()
# print(f"Pipeline run OCID: {pipeline_run.id}")
```
--------------------------------
### Apache Spark Quick Start
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/configuration/autonomous_database
Provides a quick starting point for using Apache Spark within the ADS environment. This likely includes basic setup steps, example code for a simple Spark job, and guidance on launching it. Assumes Spark is available or can be easily configured.
```python
# Example PySpark code
# from pyspark.sql import SparkSession
# Create a SparkSession
# spark = SparkSession.builder.appName("ADSSparkQuickstart").getOrCreate()
# Example DataFrame creation and operation
# data = [("Alice", 1), ("Bob", 2)]
# columns = ["name", "id"]
# df = spark.createDataFrame(data, columns)
# df.show()
# spark.stop()
```
--------------------------------
### Apache Spark Quick Start
Source: https://accelerated-data-science.readthedocs.io/en/latest/_modules/ads/feature_engineering/feature_type/ip_address
A quick start guide for using Apache Spark within the ADS environment. This covers basic setup and running a simple Spark application. Ensure Spark and necessary OCI configurations are available.
```python
from pyspark.sql import SparkSession
# Create a SparkSession
spark = SparkSession.builder \
.appName("ADS Spark Quickstart") \
.getOrCreate()
# Example: Create a DataFrame
data = [("Alice", 1), ("Bob", 2)]
columns = ["name", "id"]
df = spark.createDataFrame(data, columns)
df.show()
# Stop the SparkSession
spark.stop()
```
--------------------------------
### Install ADS with Notebook Module
Source: https://accelerated-data-science.readthedocs.io/en/latest/_sources/user_guide/cli/quickstart
Installs the `oracle-ads` package with the `notebook` extra libraries, enabling ADS usage within Oracle Cloud Infrastructure Data Science service Notebook Sessions. This module installs `ipywidgets` and `ipython`.
```bash
python3 -m pip install "oracle-ads[notebook]"
```
--------------------------------
### Quick Start for AI Forecast Operator
Source: https://accelerated-data-science.readthedocs.io/en/latest/ads.model.deployment
This example provides a quick start guide for using the AI Forecast Operator. It demonstrates the basic steps to initialize and run a forecasting task, likely involving setting up data and forecast parameters.
```python
from ads.operators.data_forecast import DataForecastOperator
# Initialize the DataForecastOperator
# You would typically provide configuration details here,
# such as data source, target column, forecast horizon, etc.
# Example initialization (parameters may vary)
# forecast_operator = DataForecastOperator(
# data=pd.read_csv("time_series_data.csv"),
# target_column="value",
# date_column="timestamp",
# freq="D", # Daily frequency
# horizon=30 # Forecast next 30 periods
# )
# Fit the operator to the data
# forecast_operator.fit()
# Generate forecasts
# forecasts = forecast_operator.predict()
print("This is a placeholder for the AI Forecast Operator Quick Start. Actual usage requires specific data and configuration.")
```
--------------------------------
### Quick Start for Apache Spark (Shell)
Source: https://accelerated-data-science.readthedocs.io/en/latest/_modules/ads/text_dataset/backends
A quick start guide for integrating and using Apache Spark within the ADS environment. This might involve setting up Spark, configuring it for OCI Data Flow, or running basic Spark applications. It typically involves shell commands for setup and execution.
```shell
# Example: Submitting a Spark job to OCI Data Flow using the OCI CLI
# Ensure you have the necessary configurations and job details.
# oci data-flow job run submit \
# --application-id \
# --file-uri "oci://@/path/to/your/spark_app.py" \
# --language PYTHON \
# --script-type MODULE \
# --driver-shape VM.Standard.E4.Flex \
# --driver-shape-config '{"ocpus": 1, "memory_in_gbs": 16}' \
# --executor-shape VM.Standard.E4.Flex \
# --executor-shape-config '{"ocpus": 1, "memory_in_gbs": 16}' \
# --num-executors 1 \
# --name "MySparkJob" \
# --arguments "--input", "oci://@/path/to/input/data" \
# --arguments "--output", "oci://@/path/to/output/results"
print("Conceptual example for submitting a Spark job to OCI Data Flow.")
```
--------------------------------
### Install ADS with Text Module
Source: https://accelerated-data-science.readthedocs.io/en/latest/_sources/user_guide/cli/quickstart
Installs the `oracle-ads` package with the `text` extra libraries for text-related tasks. This module includes libraries such as `wordcloud` and `spacy` for natural language processing and text visualization.
```bash
python3 -m pip install "oracle-ads[text]"
```
--------------------------------
### Configure core-site.xml for Resource Principals
Source: https://accelerated-data-science.readthedocs.io/en/latest/_sources/user_guide/apachespark/setup-installation
Automatically configures the core-site.xml file for authentication with OCI Object Storage using resource principals. This command populates the necessary properties for connection.
```bash
odsc core-site config -a resource_principal
```
--------------------------------
### Getting Started with PII Operator
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/operators/forecast_operator/use_cases
A guide to getting started with the PII (Personally Identifiable Information) Operator. This snippet covers the initial setup and usage for PII detection and masking.
```python
# Example: Getting started with PII Operator
# from ads.opctl.operator.lowcode.pii import PIIOperator
# Initialize the operator
# pii_op = PIIOperator()
# Configure and run PII detection
# pii_op.configure(
# data_path='path/to/your/text_data.txt',
# # other configuration options like entities, actions
# ).run()
# print("PII detection processed.")
```
--------------------------------
### Connecting to Data Catalog Metastore (Quick Start)
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/cli/opctl/local-development-setup
A quick start guide for connecting to the OCI Data Catalog metastore. This typically involves setting up necessary configurations and credentials.
```python
from ads.catalog import DataCatalog
# Initialize DataCatalog client
# Assumes OCI config is available (e.g., ~/.oci/config)
data_catalog = DataCatalog()
# Example: List catalogs
# catalogs = data_catalog.catalogs()
# for catalog in catalogs:
# print(catalog.name)
# Example: Get a specific catalog
# catalog_id = "ocid1.datacatalog.oc1.iad....your_catalog_ocid"
# catalog = data_catalog.get_catalog(catalog_id)
# print(f"Catalog Name: {catalog.name}")
```
--------------------------------
### Complete LightGBMModel Workflow Example
Source: https://accelerated-data-science.readthedocs.io/en/latest/ads
A comprehensive example showcasing the end-to-end workflow of training a LightGBM model, initializing the ADS LightGBMModel wrapper, preparing it for inference, verifying, saving, deploying, predicting, and finally deleting the deployment.
```python
>>> import lightgbm as lgb
>>> import tempfile
>>> from sklearn.model_selection import train_test_split
>>> from sklearn.datasets import load_iris
>>> from ads.model.framework.lightgbm_model import LightGBMModel
>>> iris = load_iris()
>>> X, y = iris.data, iris.target
>>> X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25)
>>> train = lgb.Dataset(X_train, label=y_train)
>>> param = {
... 'objective': 'multiclass', 'num_class': 3,
... }
>>> lightgbm_estimator = lgb.train(param, train)
>>> lightgbm_model = LightGBMModel(estimator=lightgbm_estimator, artifact_dir=tempfile.mkdtemp())
>>> lightgbm_model.prepare(inference_conda_env="generalml_p37_cpu_v1")
>>> lightgbm_model.verify(X_test)
>>> lightgbm_model.save()
>>> model_deployment = lightgbm_model.deploy()
>>> lightgbm_model.predict(X_test)
>>> lightgbm_model.delete_deployment()
```
--------------------------------
### Setup and Installation for Apache Spark
Source: https://accelerated-data-science.readthedocs.io/en/latest/_modules/ads/opctl/distributed/common/abstract_cluster_provider
Provides instructions for setting up and installing Apache Spark, likely for use within the ADS environment. This includes prerequisites and configuration steps needed to run Spark applications. Ensure Java and Scala are installed if required.
```bash
# Download Spark
# wget https://archive.apache.org/dist/spark/spark-3.x.x/spark-3.x.x-bin-hadoop3.tgz
# tar xvf spark-3.x.x-bin-hadoop3.tgz
# mv spark-3.x.x-bin-hadoop3 /opt/spark
# Set environment variables
# export SPARK_HOME=/opt/spark
# export PATH=$SPARK_HOME/bin:$PATH
# Verify installation
# $SPARK_HOME/bin/spark-shell
# For integration with ADS, further configuration might be needed
# such as setting up Spark on OCI Data Flow or a cluster manager.
```
--------------------------------
### Install Accelerated Data Science (ads) using pip
Source: https://accelerated-data-science.readthedocs.io/en/latest/_sources/user_guide/operators/recommender_operator/quickstart
Installs the 'oracle_ads' library using pip. This is the primary method for installing the library.
```bash
python3 -m pip install "oracle_ads"
```
--------------------------------
### Quick Start for Anomaly Detection Operator
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/model_serialization/genericmodel
This snippet provides a quick start guide for the Anomaly Detection Operator. It demonstrates the basic usage and configuration to get started with identifying anomalies in your data.
```python
from ads.operators.census import AnomalyDetectionOperator
from ads.common.data import ADSDataHandler
# Initialize data handler with your dataset
# Replace with your actual dataset path or OCI URI
data_path = "oci://your-bucket@your-namespace/data/your_dataset.csv"
data_handler = ADSDataHandler(path=data_path)
# Initialize the Anomaly Detection Operator
# Specify the column(s) to use for anomaly detection
anomaly_detector = AnomalyDetectionOperator(
data_handler=data_handler,
target_column='value', # Replace with your time-series or numerical column
# Other parameters can be configured here, e.g., model_type, seasonality, etc.
)
# Fit the operator to the data (train the anomaly detection model)
anomaly_detector.fit()
# Predict anomalies
# This will return a DataFrame with anomaly scores or flags
anomaly_results = anomaly_detector.predict()
print("Anomaly Detection Results:")
print(anomaly_results.head())
# You can also access the trained model
trained_model = anomaly_detector.model
print("Trained model type:", type(trained_model))
```
--------------------------------
### Data Catalog Metastore - Quick Start
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/quick_start/quick_start
A quick start guide for setting up and using the Data Catalog Metastore with Apache Spark. It covers the prerequisites and initial steps to enable data discovery and governance.
```bash
# Ensure prerequisites are met (e.g., Data Catalog service enabled, necessary permissions)
# Example: Configuring Spark to use OCI Data Catalog Metastore
# This often involves setting spark-defaults.conf properties.
# Create or modify spark-defaults.conf with the following:
# spark.sql.catalog.ocidsc = com.oracle.bigdata.catalog.spark.SparkCatalog
# spark.hadoop.fs.oci.client.config.location = "~/.oci/config"
# spark.hadoop.fs.oci.namespace = "your-namespace"
# spark.hadoop.fs.oci.region = "us-ashburn-1" # Replace with your region
# spark.hadoop.fs.oci.objectstorage.namespace = "your-namespace"
# spark.hadoop.fs.oci.objectstorage.region = "us-ashburn-1"
# spark.hadoop.fs.oci.data.catalog.enabled = "true"
# spark.hadoop.fs.oci.data.catalog.tenancy.ocid = "ocid1.tenancy.oc1..exampleuniqueid"
# spark.hadoop.fs.oci.data.catalog.compartment.ocid = "ocid1.compartment.oc1.phx.exampleuniqueid"
# spark.hadoop.fs.oci.data.catalog.data.catalog.ocid = "ocid1.datakatalogcatalog.oc1.phx.exampleuniqueid"
# After configuration, you can use Spark SQL to interact with the catalog:
# spark.sql("SHOW DATABASES")
# spark.sql("USE my_catalog.my_schema")
# spark.sql("SHOW TABLES")
```
--------------------------------
### Quick Start for AI Forecast Operator
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/operators/forecast_operator/use_cases
A concise guide to getting started with the AI Forecast Operator. This snippet provides the initial steps required to use the forecasting capabilities.
```python
# Example: Quick start for AI Forecast Operator
# from ads.opctl.operator.lowcode.forecast import ForecastOperator
# Initialize the operator
# forecast_op = ForecastOperator()
# Configure and run the forecast
# forecast_op.configure(
# data_path='path/to/your/data.csv',
# target_column='your_target_column',
# time_column='your_time_column'
# ).run()
# print("Forecast generated successfully.")
```
--------------------------------
### Configure core-site.xml for API Keys (Automated)
Source: https://accelerated-data-science.readthedocs.io/en/latest/_sources/user_guide/apachespark/setup-installation
Automatically configures the core-site.xml file for authentication with OCI Object Storage using API keys. It uses the default OCI configuration file (~/.oci/config) to populate the necessary properties.
```bash
odsc core-site config -o
```
--------------------------------
### Quick Start for ADSTuner
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/model_serialization/genericmodel
This snippet provides a quick start guide for ADSTuner, a tool for hyperparameter tuning. It demonstrates the basic setup and usage for optimizing machine learning model parameters.
```python
from ads.automl import ADSTuner
from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
# Generate sample data
X, y = make_classification(n_samples=1000, n_features=20, random_state=42)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Define the model and its hyperparameters to tune
model = RandomForestClassifier(random_state=42)
hyperparameters = {
'n_estimators': [50, 100, 200],
'max_depth': [None, 10, 20, 30],
'min_samples_split': [2, 5, 10]
}
# Initialize ADSTuner
tuner = ADSTuner(
estimator=model,
hyperparameters=hyperparameters,
max_trials=20, # Number of hyperparameter combinations to try
scoring='accuracy', # Metric to optimize
cv=3, # Number of cross-validation folds
random_state=42
)
# Start the tuning process
tuner.fit(X_train, y_train)
# Get the best hyperparameters found
best_params = tuner.best_params_
print(f"Best hyperparameters found: {best_params}")
# Get the best model trained with the best hyperparameters
best_model = tuner.best_estimator_
# Evaluate the best model on the test set
accuracy = best_model.score(X_test, y_test)
print(f"Accuracy of the best model: {accuracy:.4f}")
```
--------------------------------
### Data Catalog Metastore Quick Start
Source: https://accelerated-data-science.readthedocs.io/en/latest/_modules/ads/dataset/forecasting_dataset
This section provides a quick start guide for using the Data Catalog Metastore with ADS. It covers the initial steps required to connect to and utilize the metastore for managing data assets.
```python
from ads.catalog import DataCatalog
# Initialize DataCatalog connection
datacatalog = DataCatalog()
# Example: List available data assets
assets = datacatalog.list_assets()
for asset in assets:
print(asset.name)
```
--------------------------------
### Apache Spark Quick Start (Python)
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/model_serialization/sklearnmodel
Provides a quick start guide for using Apache Spark with the ADS library. This includes setting up Spark and running basic Spark operations.
```Python
from ads.providers.spark.spark_session import get_spark_session
# Get a Spark session
session = get_spark_session()
# Example: Create a Spark DataFrame
data = [("Alice", 1), ("Bob", 2)]
columns = ["name", "id"]
df = session.createDataFrame(data, columns)
df.show()
# Stop the Spark session when done
session.stop()
```
--------------------------------
### PII Operator Getting Started
Source: https://accelerated-data-science.readthedocs.io/en/latest/_modules/ads/dataset/forecasting_dataset
This section provides a starting guide for the PII (Personally Identifiable Information) Operator. It explains how to begin using the operator for detecting and handling sensitive information in text.
```python
from ads.operators.data_science.pii import PIIOperator
# Initialize the operator
pii_op = PIIOperator(
# Provide configuration like sensitive entity types to detect
sensitive_types=['EMAIL', 'PHONE_NUMBER']
)
# Example text to analyze
text = "Contact us at example@example.com or call 123-456-7890."
# Analyze text for PII
results = pii_op.analyze(text)
print(results)
```
--------------------------------
### Quick Start for Recommender Operator
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/jobs/policies
A quick start guide for using the Recommender Operator. It outlines the essential steps to configure and deploy a recommendation system.
```yaml
type: "Recommender"
name: "my-recommender"
inputs:
```
--------------------------------
### Quick Start for Recommender Operator
Source: https://accelerated-data-science.readthedocs.io/en/latest/ads.model.deployment
This snippet offers a quick start guide for the Recommender Operator. It outlines the initial steps to set up and use the operator for generating recommendations.
```python
from ads.operators.recommender import RecommenderOperator
# Initialize the RecommenderOperator
# Configuration typically includes user-item interaction data.
# Example initialization (parameters may vary)
# recommender = RecommenderOperator(
# data=pd.read_csv("interactions.csv"), # User, Item, Rating columns
# user_col="user_id",
# item_col="item_id",
# rating_col="rating"
# )
# Train the recommender model
# recommender.fit()
# Get recommendations for a user
# recommendations = recommender.predict(user_id="user123")
print("This is a placeholder for the Recommender Operator Quick Start. Actual usage requires specific data and configuration.")
```
--------------------------------
### Python Code for Apache Spark Quick Start
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/apachespark/spark
Illustrates a quick start example for using Apache Spark within the ADS environment. This snippet likely involves initializing a Spark session and performing a basic operation, demonstrating how to get started with Spark for big data processing.
```python
from pyspark.sql import SparkSession
# Create a SparkSession
spark = SparkSession.builder \
.appName("ADSSparkQuickStart") \
.getOrCreate()
# Example: Create a simple DataFrame
data = [("Alice", 1), ("Bob", 2)]
columns = ["name", "id"]
df = spark.createDataFrame(data, columns)
df.show()
# Example: Performing a simple transformation
processed_df = df.filter(df.id > 1)
processed_df.show()
# Stop the SparkSession
spark.stop()
```
--------------------------------
### Setup and Installation for Apache Spark on OCI
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/jobs/policies
Covers the necessary steps for setting up and installing Apache Spark within the Oracle Cloud Infrastructure (OCI) environment. This includes prerequisites and configuration details.
```bash
# Example: Installing Spark on a compute instance
sudo apt-get update
sudo apt-get install -y openjdk-8-jdk scala
# Download and extract Spark
cd /opt
# Replace with the actual Spark download URL
wget http://archive.apache.org/dist/spark/spark-3.1.2/spark-3.1.2-bin-hadoop3.2.tgz
tar xvf spark-3.1.2-bin-hadoop3.2.tgz
# Set environment variables (e.g., in ~/.bashrc)
export SPARK_HOME=/opt/spark-3.1.2-bin-hadoop3.2
export PATH=$SPARK_HOME/bin:$PATH
source ~/.bashrc
```
--------------------------------
### Quick Start for Anomaly Detection Operator (Python)
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/secrets/quick_start
Provides a quick start guide for using the Anomaly Detection Operator. This section offers basic code examples to help users quickly begin detecting anomalies in their data.
```python
# Example quick start for Anomaly Detection Operator
# from ads.opctl.operator.factory import OperatorFactory
#
# anomaly_operator = OperatorFactory.create_operator(
# operator_name='anomaly_detection',
# dataset=my_timeseries_data,
# target_column='value'
# )
# anomaly_operator.execute()
# print(anomaly_operator.get_artifact('anomalies'))
```
--------------------------------
### Apache Spark Quick Start on OCI Data Flow
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/model_training/model_evaluation/regression
A quick start guide for using Apache Spark on Oracle Cloud Infrastructure (OCI) Data Flow. This example demonstrates basic Spark operations within the OCI environment.
```python
# Example Spark application script for OCI Data Flow
from pyspark.sql import SparkSession
spark = SparkSession.builder.appName("OCIDataFlowSparkApp").getOrCreate()
data = [("Alice", 1), ("Bob", 2)]
columns = ["name", "id"]
df = spark.createDataFrame(data, columns)
df.show()
spark.stop()
print("Spark application completed successfully.")
```
--------------------------------
### Python: Data Catalog Metastore Quick Start with ADS
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/cli/opctl/_template/monitoring
Provides a quick start guide for using the Data Catalog Metastore with ADS. This involves connecting to the metastore, potentially registering tables, and querying metadata for data discovery.
```python
# Example conceptual Python code for Data Catalog Metastore with ADS
# from ads.catalog import DataCatalog
# # Initialize DataCatalog client
# dc = DataCatalog()
# # Example: Get information about a metastore
# # metastore_info = dc.get_metastore('your-metastore-name')
# # print(metastore_info)
# # Example: List tables in a database
# # tables = dc.list_tables(metastore_name='your-metastore-name', database_name='your-database-name')
# # for table in tables:
# # print(table.display_name)
print("Conceptual code for Data Catalog Metastore Quick Start with ADS.")
```
--------------------------------
### Data Catalog Metastore Quick Start
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/big_data_service/connect
A quick start guide for using the Data Catalog metastore with Apache Spark in ADS. This section focuses on connecting Spark to OCI Data Catalog for metadata management. Requires Data Catalog and Spark setup.
```python
from pyspark.sql import SparkSession
# Configure Spark session to connect to OCI Data Catalog metastore
spark = SparkSession.builder \
.appName("ADS Data Catalog Metastore") \
.config("spark.sql.catalog.ocidatacatalog", "com.oracle.bigdata.catalog.oci.OCIDataCatalogCatalog") \
.config("spark.sql.catalog.ocidatacatalog.tenant.id", "your_tenant_id") \
.config("spark.sql.catalog.ocidatacatalog.region.id", "your_region_id") \
.config("spark.sql.catalog.ocidatacatalog.credentials.file", "~/.oci/config") \
.getOrCreate()
# Example: List databases in the metastore
# print(spark.catalog.listDatabases())
# Example: Query a table using the metastore
# df = spark.sql("SELECT * FROM ocidatacatalog.your_database.your_table LIMIT 10")
# df.show()
```
--------------------------------
### Deploy LightGBM Model with ADS
Source: https://accelerated-data-science.readthedocs.io/en/latest/_sources/user_guide/model_registration/quick_start
This snippet illustrates how to register and deploy a LightGBM model using ADS. It covers model training, preparation, verification, and saving. This requires the 'ads', 'lightgbm', and 'sklearn' libraries.
```python3
import tempfile
import ads
import lightgbm as lgb
from ads.model.framework.lightgbm_model import LightGBMModel
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
ads.set_auth(auth="resource_principal")
# Load dataset and Prepare train and test split
iris = load_iris()
X, y = iris.data, iris.target
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25)
# Train a XBoost Classifier model
train = lgb.Dataset(X_train, label=y_train)
param = {
'objective': 'multiclass', 'num_class': 3,
}
lightgbm_estimator = lgb.train(param, train)
# Instantiate ads.model.lightgbm_model.XGBoostModel using the trained LGBM Model
lightgbm_model = LightGBMModel(estimator=lightgbm_estimator, artifact_dir=tempfile.mkdtemp())
# Autogenerate score.py, serialized model, runtime.yaml, input_schema.json and output_schema.json
lightgbm_model.prepare(
inference_conda_env="generalml_p38_cpu_v1",
X_sample=X_train,
y_sample=y_train,
)
# Verify generated artifacts
lightgbm_model.verify(X_test)
# Register LightGBM model
model_id = lightgbm_model.save(display_name="LightGBM Model")
```
--------------------------------
### Apache Spark Quick Start in Python
Source: https://accelerated-data-science.readthedocs.io/en/latest/ads.pipeline.builders
Provides a quick start guide for using Apache Spark with Python. This snippet assumes Spark is installed and configured, and demonstrates basic Spark operations like creating a SparkSession and performing simple data manipulations.
```python
from pyspark.sql import SparkSession
# Create a SparkSession
spark = SparkSession.builder \
.appName("SparkQuickStart") \
.getOrCreate()
# Create a sample DataFrame
data = [("Alice", 1), ("Bob", 2), ("Charlie", 3)]
columns = ["name", "id"]
df = spark.createDataFrame(data, columns)
# Show the DataFrame
df.show()
# Perform a simple transformation (e.g., filter)
filtered_df = df.filter(df.id > 1)
filtered_df.show()
# Stop the SparkSession
spark.stop()
```
--------------------------------
### Data Science Jobs Quick Start
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/big_data_service/connect
Provides a quick start guide for using Data Science Jobs in ADS. This covers the essential steps to submit and manage job runs for data processing and model training tasks. Requires ADS CLI setup.
```bash
# Example: Submit a simple Python job
ads job run python \
--file "path/to/your/script.py" \
--project-id "your_project_id" \
--compartment-id "your_compartment_id" \
--job-display-name "Quick Start Job"
```
--------------------------------
### Diagnose Infrastructure Setup with ADS CLI
Source: https://accelerated-data-science.readthedocs.io/en/latest/_sources/user_guide/model_training/distributed_training/developer/developer
Checks the infrastructure setup for Data Science Jobs using the 'ads opctl check' command. It starts a single-node 'jobrun' using the container image specified in 'train.yaml' and generates a diagnostic report saved to an HTML file.
```bash
ads opctl check -f train.yaml --output infra_report.html
```
--------------------------------
### Quick Start for Recommender Operator
Source: https://accelerated-data-science.readthedocs.io/en/latest/user_guide/model_serialization/tensorflowmodel
This example provides a quick start for the Recommender Operator. It outlines the fundamental parameters required to set up a recommendation system, including specifying user and item data, and the type of recommendation model to use.
```python
from ads.opctl.operator.lowcode.recommender.operator import RecommenderOperator
# Instantiate the operator
operator = RecommenderOperator(
name="my-recommender-job",
user_data="oci://bucketName@namespace/data/user_interactions.csv",
item_data="oci://bucketName@namespace/data/item_metadata.csv",
user_col="user_id",
item_col="item_id",
recommendation_type="user_based"
)
# Run the operator
run = operator.run()
# Access results
print(run.show_output())
print(run.get_recommendations_uri())
```
--------------------------------
### Install ADS with Viz Module
Source: https://accelerated-data-science.readthedocs.io/en/latest/_sources/user_guide/cli/quickstart
Installs the `oracle-ads` package with the `viz` extra libraries for visualization tasks. This module includes key packages like `bokeh`, `folium`, and `seaborn`, along with related libraries, to support data visualization.
```bash
python3 -m pip install "oracle-ads[viz]"
```
--------------------------------
### Apache Spark Quick Start with ADS
Source: https://accelerated-data-science.readthedocs.io/en/latest/_modules/ads/feature_engineering/feature_type/category
A quick start guide for using Apache Spark with the Accelerated Data Science (ADS) library. This section covers the basic setup and usage for running Spark applications on OCI Data Flow. Assumes OCI environment is configured.
```python
from ads.spark.init import init_spark
# Initialize Spark session within ADSspark = init_spark(app_name="my-spark-app")
# Example Spark operationdata = [("Alice", 1), ("Bob", 2)]columns = ["name", "id"]
df = spark.createDataFrame(data, columns)
df.show()
# Stop Spark session
spark.stop()
```