{ "cells": [ { "cell_type": "markdown", "id": "341bc47b", "metadata": {}, "source": [ "[](https://colab.research.google.com/github/usnistgov/AFL-agent/blob/main/docs/source/tutorials/using_prefab.ipynb)\n", "\n", "# Using Prefabricated Pipelines\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "94aae7f7", "metadata": {}, "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2" ] }, { "cell_type": "code", "execution_count": 2, "id": "df5b7fd4", "metadata": {}, "outputs": [], "source": [ "# Import required libraries\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "from AFL.double_agent import *\n", "from AFL.double_agent.data import example_dataset1\n", "from AFL.double_agent.prefab import load_prefab, list_prefabs, combine_prefabs" ] }, { "cell_type": "markdown", "id": "573d1b1d", "metadata": {}, "source": [ "Introduction\n", "-----------\n", "\n", "Prefabricated pipelines (prefabs) are pre-configured pipelines that can be easily loaded and used in your projects. \n", "This tutorial will guide you through the process of loading and using prefabricated pipelines from the ``AFL.double_agent.prefab`` module.\n", "\n", "Prefabricated pipelines are particularly useful when:\n", "\n", "* You have common processing steps that you use frequently\n", "* You want to share pipeline configurations with colleagues\n", "* You want to create building blocks that can be combined into more complex pipelines\n", "\n", "In this tutorial, we'll:\n", "\n", "1. Load an example dataset\n", "2. Load a prefabricated pipeline \n", "3. Inspect the pipeline\n", "4. Customize the pipeline to work with our dataset\n", "5. Execute the pipeline and analyze the results\n", "\n", "Let's get started!\n", "\n" ] }, { "cell_type": "markdown", "id": "3b97422d", "metadata": {}, "source": [ "## Google Colab Setup\n", "\n", "Only uncomment and run the next cell if you are running this notebook in Google Colab or if don't already have the AFL-agent package installed." ] }, { "cell_type": "code", "execution_count": 3, "id": "26dfcff9", "metadata": {}, "outputs": [], "source": [ "# !pip install git+https://github.com/usnistgov/AFL-agent.git" ] }, { "cell_type": "markdown", "id": "34e6a733", "metadata": {}, "source": [ "\n", "## Loading an Example Dataset\n", "\n", "First, let's load an example dataset from the ``AFL.double_agent.data`` module:\n" ] }, { "cell_type": "code", "execution_count": 4, "id": "76b65e22", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.Dataset> Size: 164kB\n", "Dimensions: (sample: 100, component: 2, x: 150, grid: 2500)\n", "Coordinates:\n", " * component (component) <U1 8B 'A' 'B'\n", " * x (x) float64 1kB 0.001 0.001047 0.001097 ... 0.9547 1.0\n", "Dimensions without coordinates: sample, grid\n", "Data variables:\n", " composition (sample, component) float64 2kB ...\n", " ground_truth_labels (sample) int64 800B ...\n", " measurement (sample, x) float64 120kB ...\n", " composition_grid (grid, component) float64 40kB ...
<xarray.Dataset> Size: 807kB\n", "Dimensions: (sample: 100, component: 2, x: 150,\n", " grid: 2500, log_x: 250)\n", "Coordinates:\n", " * component (component) <U1 8B 'A' 'B'\n", " * x (x) float64 1kB 0.001 0.001047 ... 0.9547 1.0\n", " * log_x (log_x) float64 2kB -3.0 -2.988 ... 0.0\n", "Dimensions without coordinates: sample, grid\n", "Data variables:\n", " composition (sample, component) float64 2kB ...\n", " ground_truth_labels (sample) int64 800B ...\n", " measurement (sample, x) float64 120kB ...\n", " composition_grid (grid, component) float64 40kB 0.0 0.0 ... 25.0\n", " normalized_composition_grid (grid, component) float64 40kB 0.0 0.0 ... 1.0\n", " normalized_composition (sample, component) float64 2kB 0.1935 ... 0...\n", " measurement_derivative0 (sample, log_x) float64 200kB 6.306 ... 0.3073\n", " measurement_derivative1 (sample, log_x) float64 200kB -3.828 ... -0....\n", " measurement_derivative2 (sample, log_x) float64 200kB -1.838 ... -0....