### Manual Audit Implementation with Venturalitica Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/docs/quickstart.md Demonstrates the manual steps equivalent to the quickstart function, including loading data from UCI repository, defining policies, and running the audit using vl.enforce. This shows the underlying components of the quickstart process. ```python from ucimlrepo import fetch_ucirepo import venturalitica as vl # 1. Load Data (The "Risk Source") dataset = fetch_ucirepo(id=144) df = dataset.data.features df['class'] = dataset.data.targets # 2. Define the Policy (The "Law") # We load a pre-defined policies/risks.oscal.yaml # 3. Run the Audit (The "Test") # This automatically generates the Evidence Bill of Materials (BOM) with vl.monitor("manual_audit"): vl.enforce( data=df, target="class", # The outcome (True/False) gender="Attribute9", # Protected Group A age="Attribute13", # Protected Group B policy="risks.oscal.yaml" ) ``` -------------------------------- ### Install Venturalitica SDK Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/starlight/src/content/docs/quickstart.mdx Installs the Venturalitica SDK using pip. Optional extras can be installed for additional capabilities like fairness metrics, dashboard, agent support, energy tracking, or a full installation. ```bash pip install venturalitica ``` -------------------------------- ### Run First Audit with Venturalitica Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/docs/quickstart.md Executes the quickstart function from the Venturalitica SDK to perform an initial audit on the 'loan' scenario. This function automates data loading, policy enforcement, and evidence recording. ```python import venturalitica as vl vl.quickstart('loan') ``` -------------------------------- ### Quickstart: Run Bias Audit on UCI Dataset Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/README.md A simple Python script to quickly start using the Venturalítica SDK. It automatically downloads the UCI German Credit dataset and runs a bias audit, providing immediate feedback on fairness. ```python import venturalitica as vl # Auto-downloads UCI German Credit and runs bias audit results = vl.quickstart('loan') ``` -------------------------------- ### Import Venturalítica and Check Version (Python) Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/notebooks/00-quickstart.ipynb Imports the Venturalítica library and prints its version. This is a standard first step to ensure the SDK is installed and accessible. ```python import venturalitica as vl print(f"Venturalítica version: {vl.__version__}") ``` -------------------------------- ### Quickstart Venturalitica SDK Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/starlight/src/content/docs/full-lifecycle.mdx Performs a quick smoke test of the Venturalitica SDK by running a 'loan' scenario. It checks for expected results, indicating a basic setup is functional. ```python import venturalitica as vl results = vl.quickstart("loan") # Expected: 2 PASS, 1 FAIL (age disparity) ``` -------------------------------- ### Run Quickstart Audit with Loan Policy (Python) Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/notebooks/00-quickstart.ipynb Executes a pre-defined fairness audit for loan applications using the `quickstart` function. This function automatically fetches the German Credit dataset, loads a loan fairness policy, and generates a report. ```python vl.quickstart('loan') ``` -------------------------------- ### Run Quickstart Demo with Venturalitica SDK Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/starlight/src/content/docs/reference/api.mdx The `quickstart()` function provides a fast way to demonstrate the Venturalitica SDK's capabilities by running a pre-configured bias audit on a standard dataset. It accepts a scenario name and an optional verbose flag to control console output. Internally, it sets up a dataset, loads an OSCAL policy, and calls `enforce()`. ```python import venturalitica as vl results = vl.quickstart("loan") ``` -------------------------------- ### Run Quickstart Bias Audit Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/starlight/src/content/docs/quickstart.mdx Executes a pre-defined bias audit using the Venturalitica SDK's quickstart function. This function automatically loads a dataset and a built-in policy to perform the audit. ```python import venturalitica as vl vl.quickstart('loan') ``` -------------------------------- ### Run Quickstart Bias Audit (Python) Source: https://context7.com/venturalitica/venturalitica-sdk/llms.txt Executes a 60-second bias audit demo using the `quickstart` function. It automatically downloads a pre-configured dataset (UCI German Credit) and uses an embedded OSCAL policy for fairness checks, providing a summary of compliance results. ```python import venturalitica as vl # Run pre-configured loan credit scoring bias audit # Auto-downloads UCI German Credit dataset (1000 samples) # Uses embedded OSCAL policy for fairness checks results = vl.quickstart('loan') # Output: # [Venturalítica] 🎓 Scenario: Credit Scoring Fairness # [Venturalítica] 📊 Loaded: UCI Dataset #144 (1000 samples) # [Venturalítica] 🛡️ Policy: Embedded (no file required) # # CONTROL DESCRIPTION ACTUAL LIMIT RESULT # ──────────────────────────────────────────────────────────────────────────────────────────────── # credit-data-imbalance Data Quality 0.431 > 0.2 ✅ PASS # credit-data-bias Disparate impact 0.836 > 0.8 ✅ PASS # credit-age-disparate Age disparity 0.361 > 0.5 ❌ FAIL # ──────────────────────────────────────────────────────────────────────────────────────────────── # Audit Summary: ❌ VIOLATION | 2/3 controls passed # # 🎉 Aha! Moment: Age bias detected in UCI German Credit dataset! # Returns List[ComplianceResult] for programmatic access for result in results: print(f"{result.control_id}: {result.passed} (value: {result.actual_value})") ``` -------------------------------- ### Install Venturalitica SDK using uv or pip Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/docs/academy/index.md Installs the Venturalitica SDK from its GitHub repository. It supports installation using either 'uv' for faster performance or the standard 'pip' package manager. ```bash uv pip install git+https://github.com/Venturalitica/venturalitica-sdk.git ``` ```bash pip install git+https://github.com/Venturalitica/venturalitica-sdk.git ``` -------------------------------- ### Install Venturalitica SDK Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/starlight/src/content/docs/full-lifecycle.mdx Installs the Venturalitica SDK using pip. Optional extras like fairness metrics can be installed with `pip install "venturalitica[metrics]"`. ```bash pip install venturalitica ``` -------------------------------- ### Install Venturalítica SDK (Bash) Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/docs/index.md Provides the command to install the Venturalítica SDK directly from its GitHub repository using pip. This ensures you have the latest version for local deployment. ```bash pip install git+https://github.com/Venturalitica/venturalitica-sdk.git ``` -------------------------------- ### List Available Scenarios Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/docs/api.md Retrieves a dictionary containing all available pre-configured scenarios and their corresponding descriptions. This utility function helps users understand the options for the `quickstart` function. ```python import venturalitica as vl available_scenarios = vl.list_scenarios() print(available_scenarios) ``` -------------------------------- ### Manual Bias Audit Workflow Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/starlight/src/content/docs/quickstart.mdx Demonstrates the manual steps involved in running a bias audit, including data loading, policy definition (using an OSCAL file), and enforcing the audit with specified attributes and a target. ```python from ucimlrepo import fetch_ucirepo import venturalitica as vl # 1. Load Data (The "Risk Source") dataset = fetch_ucirepo(id=144) df = dataset.data.features df['class'] = dataset.data.targets # 2. Define the Policy (The "Law") # quickstart() uses a built-in policy dict. # In real projects, you write your own OSCAL YAML file. # See the Full Lifecycle guide for a copy-paste example. # 3. Run the Audit (The "Test") # This automatically generates the Evidence Bill of Materials (BOM) with vl.monitor("manual_audit"): vl.enforce( data=df, target="class", # The outcome (True/False) gender="Attribute9", # Protected Group A age="Attribute13", # Protected Group B policy="data_policy.oscal.yaml" # Your OSCAL policy file ) ``` -------------------------------- ### GitHub Actions Workflow for Venturalitica Compliance Source: https://context7.com/venturalitica/venturalitica-sdk/llms.txt Example GitHub Actions workflow demonstrating how to set up a compliance gate using Venturalitica's Strict Mode. The workflow installs the SDK and runs a Python script to enforce compliance policies, failing the build if any control fails or configuration is missing. ```yaml name: Compliance Gateon: [push, pull_request] jobs: compliance: runs-on: ubuntu-latest env: VENTURALITICA_STRICT: true steps: - uses: actions/checkout@v3 - name: Run Compliance Audit run: | pip install venturalitica python -c " import venturalitica as vl import pandas as pd df = pd.read_csv('data/test.csv') vl.enforce(data=df, target='label', policy='policy.yaml') " # Build fails if any control fails or config is missing ``` -------------------------------- ### Core Functions - quickstart Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/docs/api.md Runs a pre-configured bias audit demo on a standard dataset. It accepts a scenario name and an optional verbose flag. ```APIDOC ## POST /quickstart ### Description Run a pre-configured bias audit demo on a standard dataset. ### Method POST ### Endpoint /quickstart ### Parameters #### Query Parameters - **scenario** (str) - Required - Predefined scenario: `'loan'`, `'hiring'`, `'health'`. - **verbose** (bool) - Optional - Whether to print the structured table report to the console. ### Response #### Success Response (200) - **results** (List[ComplianceResult]) - A list of compliance results from the audit. ### Request Example ```json { "scenario": "loan", "verbose": true } ``` ### Response Example ```json { "results": [ { "metric": "Demographic Parity", "value": 0.85, "threshold": 0.8 } ] } ``` ``` -------------------------------- ### Quickstart Audit with Venturalítica SDK (Python) Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/docs/index.md Demonstrates how to perform a quick audit using the Venturalítica SDK with a single line of Python code. This function automatically records evidence for compliance. ```python import venturalitica as vl # 1. Run Audit (Auto-Records Evidence) results = vl.quickstart('loan') ``` -------------------------------- ### Install Venturalitica SDK using pip (Bash) Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/RELEASE_NOTES.md Command to install a specific version of the Venturalitica SDK using pip. This is useful for users who need to ensure they have version 0.5.0 installed. ```bash pip install venturalitica-sdk==0.5.0 ``` -------------------------------- ### Launch Venturalítica UI Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/docs/annex-iv.md Starts the Venturalítica Dashboard from the project's root directory. This UI allows for interactive generation of Annex IV documentation. ```bash venturalitica ui ``` -------------------------------- ### Clone Venturalitica SDK Samples Repository Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/docs/academy/index.md Clones the Venturalitica SDK samples repository to your local machine. This repository serves as the working directory for various levels of AI governance training and practical examples. ```bash git clone https://github.com/venturalitica/venturalitica-sdk-samples.git cd venturalitica-sdk-samples/scenarios/loan-credit-scoring ``` -------------------------------- ### Run Quickstart Bias Audit Demo Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/docs/api.md Executes a pre-configured bias audit demo using a standard dataset. It requires a scenario string and an optional verbose boolean for console output. The function returns a list of ComplianceResult objects. ```python import venturalitica as vl # Example usage: results = vl.quickstart(scenario='loan', verbose=True) ``` -------------------------------- ### Import Libraries and Check Venturalítica Version (Python) Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/notebooks/01-training-tutorial.ipynb Imports necessary libraries for data manipulation, ML modeling, and Venturalítica SDK. It also prints the installed Venturalítica version. ```python from ucimlrepo import fetch_ucirepo from sklearn.model_selection import train_test_split from sklearn.ensemble import RandomForestClassifier import venturalitica as vl import pandas as pd import yaml print("Venturalítica version:", vl.__version__ if hasattr(vl, '__version__') else '0.2.0') ``` -------------------------------- ### Install Optional Dependencies for Probes Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/starlight/src/content/docs/reference/probes.mdx Some Venturalitica SDK probes have optional dependencies that enhance their functionality. The HardwareProbe can utilize `psutil` for detailed CPU and memory usage, while the CarbonProbe requires `codecarbon` for tracking energy consumption and carbon emissions. These can be installed using pip. ```bash pip install psutil codecarbon ``` -------------------------------- ### Artifact Tracking with Input/Output Paths (Python) Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/starlight/src/content/docs/reference/probes.mdx Illustrates how to use the ArtifactProbe by specifying input and output file paths during monitor initialization. This captures snapshots of artifacts at the start and end of the monitored execution. ```python with vl.monitor("training", inputs=["data/train.csv"], outputs=["models/credit_model.pkl"]): model.fit(X, y) ``` -------------------------------- ### Install mdpdf for Document Conversion Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/starlight/src/content/docs/full-lifecycle.mdx Installs the 'mdpdf' Python package, which is used to convert Markdown files to PDF format. This is typically used after generating regulatory documents like Annex IV. ```bash pip install mdpdf ``` -------------------------------- ### Install Venturalitica SDK using uv (Bash) Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/RELEASE_NOTES.md Command to add a specific version of the Venturalitica SDK to a project using the uv package installer. This is an alternative to pip for managing Python dependencies. ```bash uv add venturalitica-sdk==0.5.0 ``` -------------------------------- ### Run Venturalitica UI Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/docs/academy/level2_integrator.md This command starts the Venturalitica UI, allowing for verification of shipped code and results. It is a prerequisite for checking policy status and risk treatment. ```bash uv run venturalitica ui ``` -------------------------------- ### Group Controls in YAML Policy Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/starlight/src/content/docs/guides/policy-authoring.mdx This YAML example demonstrates how to group multiple controls within a single policy file under logical descriptions. It shows sections for 'Data Quality Controls', 'Fairness Controls', and 'Privacy Controls', allowing for organized policy definitions. ```yaml assessment-plan: metadata: title: "Comprehensive AI Assurance Policy" control-implementations: - description: "Data Quality Controls (Article 10)" implemented-requirements: - control-id: dq-001 # ... - control-id: dq-002 # ... - description: "Fairness Controls (Article 9)" implemented-requirements: - control-id: fair-001 # ... - description: "Privacy Controls (GDPR)" implemented-requirements: - control-id: priv-001 # ... ``` -------------------------------- ### Convert Markdown to PDF using mdpdf Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/docs/academy/level4_annex_iv.md This command installs the mdpdf Python package and then uses it to convert a Markdown file (Annex_IV.md) into a PDF document. Ensure you have Python and pip/uv installed. ```bash uv pip install mdpdf uv run mdpdf Annex_IV.md ``` -------------------------------- ### Educational Audit Control Description Example Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/README.md An example of a control definition within a policy file that includes an educational description. This description explains the rationale behind the data quality check, specifically regarding class imbalance. ```yaml - control-id: data-quality-check description: "Data Quality: Minority class should represent at least 20% to avoid Class Imbalance" ``` -------------------------------- ### Run First AI Audit with Venturalitica SDK Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/docs/academy/index.md Executes a quickstart function from the Venturalitica SDK to perform an initial audit on a loan credit scoring model. This function automatically downloads a dataset, loads a predefined policy, and audits the model, providing a PASS/FAIL result for each control. ```python import venturalitica as vl # Run the 'loan' scenario vl.quickstart('loan') ``` -------------------------------- ### Install Venturalítica SDK Packages Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/starlight/src/content/docs/index.mdx Installs the Venturalítica SDK with different feature sets. The core package is required, while others like 'metrics', 'dashboard', 'agentic', or 'full' can be added for extended functionality. These commands are executed using pip. ```bash pip install venturalitica pip install "venturalitica[metrics]" pip install "venturalitica[dashboard]" pip install "venturalitica[agentic]" pip install "venturalitica[full]" ``` -------------------------------- ### Load UCI German Credit Dataset (Python) Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/notebooks/01-training-tutorial.ipynb Loads the UCI German Credit dataset using `fetch_ucirepo` and splits it into training and testing sets. It prints the total number of samples loaded. ```python dataset = fetch_ucirepo(id=144) df = dataset.data.features.copy() df['class'] = dataset.data.targets train_df, test_df = train_test_split(df, test_size=0.2, random_state=42) print(f"Loaded {len(df)} samples.") df.head() ``` -------------------------------- ### Enforce Multiple Policies with Python SDK Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/starlight/src/content/docs/guides/policy-authoring.mdx Illustrates enforcing multiple policies (data and model) in a single call using the Venturalitica Python SDK. It explains how controls are skipped if required inputs are missing and shows how to supply all necessary inputs for both policy types to be evaluated. ```python # Only data-policy controls will run here because # 'prediction' is not provided — model-policy controls are skipped. vl.enforce( data=df, target="class", gender="Attribute9", policy=["data_policy.oscal.yaml", "model_policy.oscal.yaml"] ) # To evaluate both policies, supply all required inputs: vl.enforce( data=test_df, target="class", prediction="y_pred", gender="Attribute9", policy=["data_policy.oscal.yaml", "model_policy.oscal.yaml"] ) ``` -------------------------------- ### Monitor Model Training with vl.monitor Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/notebooks/01-training-tutorial.ipynb This code snippet shows how to use `vl.monitor` to track metadata during model training. It wraps the `model.fit` method within a `vl.monitor` context, allowing for the collection of metrics such as duration, hardware usage, and carbon emissions. The monitor is started with a specific name and stopped automatically when the context manager exits. ```python model = RandomForestClassifier(n_estimators=100, random_state=42) with vl.monitor(name="RandomForest-Credit"): model.fit(X_train, y_train) predictions = model.predict(X_test) ``` -------------------------------- ### Monitor Model Training with Venturalitica Python Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/starlight/src/content/docs/reference/api.mdx This snippet demonstrates how to use the `vl.monitor` context manager to automatically collect probes during model training. It initializes 7 probes that capture various aspects of the training environment and process, such as hardware usage, CO2 emissions, software bill of materials, data lineage, and code analysis. Evidence is saved to a local directory. ```python import venturalitica as vl with vl.monitor("credit_model_v1"): model.fit(X_train, y_train) vl.enforce(data=df, policy="policy.oscal.yaml", target="class") ``` -------------------------------- ### Verify Data Policy with Venturalitica SDK (Python) Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/docs/tutorials/01_writing_policy.md Demonstrates how to use the Venturalitica SDK in Python to load sample data and enforce a data policy defined in a YAML file. ```python import venturalitica as vl from venturalitica.quickstart import load_sample # 1. Load the 'Approved' Dataset (Mock) data = load_sample('loan') # 2. Dry Run the Policy try: vl.enforce( data=data, target="class", gender="Attribute9", # "Personal status and sex" in German Credit Data policy="data_policy.yaml" ) print("✅ Policy is valid syntax and passes baseline data.") except Exception as e: print(f"❌ Policy Error: {e}") ``` -------------------------------- ### Train Random Forest Model with Python Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/docs/training.md Trains a RandomForestClassifier model using scikit-learn on the pre-processed training data. It then generates predictions on the test set for subsequent model auditing. ```python from sklearn.ensemble import RandomForestClassifier print("🤖 Training Model...") model = RandomForestClassifier(n_estimators=100, random_state=42) model.fit(X_train, y_train) # Generate predictions for the next audit predictions = model.predict(X_test) ``` -------------------------------- ### Enforce Data and Model Policies using Python SDK Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/starlight/src/content/docs/guides/policy-authoring.mdx Demonstrates how to use the Venturalitica Python SDK to enforce data and model policies. It shows separate calls for pre-training data audits and post-training model audits, highlighting the `enforce` function with different dataframes and policy files. ```python # Pre-training: audit the data vl.enforce(data=train_df, target="class", gender="Attribute9", policy="data_policy.oscal.yaml") # Post-training: audit the model vl.enforce(data=test_df, target="class", prediction="y_pred", gender="Attribute9", policy="model_policy.oscal.yaml") ``` -------------------------------- ### Define Fairness Policy for Auditing Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/README.md An example YAML file defining a fairness policy for the Venturalítica SDK. This policy specifies checks for gender-based approval rates using the demographic parity difference metric. ```yaml assessment-plan: uuid: my-policy metadata: title: "Fairness Policy" reviewed-controls: control-selections: - include-controls: - control-id: gender-check description: "Approval rates must be similar across genders" props: - name: metric_key value: demographic_parity_diff - name: threshold value: "0.10" - name: operator value: "<" ``` -------------------------------- ### Run Loan Scenario with Alternative Metrics Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/METRICS_GUIDE.md Executes a Python script demonstrating the use of alternative fairness metrics within a loan scenario. This is useful for understanding how different fairness definitions apply in a practical context. ```bash cd scenarios/loan-mlflow-sklearn python 02_alternative_metrics_demo.py ``` -------------------------------- ### Load Sample Dataset by Scenario Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/docs/api.md Loads a sample dataset from the UCI repository corresponding to a specified scenario. The loaded data is returned as a Pandas DataFrame, suitable for use with other Venturalitica functions like `enforce` or `quickstart`. ```python import venturalitica as vl # Example: Load the 'loan' scenario dataset dataframe = vl.load_sample(scenario='loan') print(dataframe.head()) ``` -------------------------------- ### Automatic Governance with vl.wrap - Python Source: https://github.com/venturalitica/venturalitica-sdk/blob/main/notebooks/01-training-tutorial.ipynb This code snippet shows how to automatically execute audits using `vl.wrap`. It preprocesses the data, wraps a Scikit-Learn model, and then calls `.fit()` with the original training data and attribute mappings. This automates the audit process every time the model is trained or used for prediction. ```python # Pre-processing as before df_encoded = pd.get_dummies(df.drop(columns=['class'])) X_train, X_test, y_train, y_test = train_test_split( df_encoded, df['class'].values.ravel(), test_size=0.2, random_state=42 ) # Wrap your model base_model = RandomForestClassifier(n_estimators=100, random_state=42) governed_model = vl.wrap(base_model, policy="policy.oscal.yaml") # Audits automated! Just provide the raw data for attribution mapping governed_model.fit(X_train, y_train, audit_data=train_df, gender="Attribute9", age="Attribute13") ```