Skip to main content

AFL-agent: Autonomous Active Learning Agent for Material Science

Documentation

AFL-agent is a Python library that implements the autonomous active learning agent described in the manuscript "Autonomous Small-Angle Scattering for Accelerated Soft Material Formulation Optimization". The library is designed to autonomously guide experimental measurement campaigns to efficiently map phase boundaries in soft material formulations using advanced machine learning techniques.

Overview

The AFL-agent library offers robust tools for building autonomous active learning agents tailored for material science applications. It integrates machine learning techniques with experimental design strategies to optimize experimental campaigns and efficiently map phase boundaries and optimize material properties in soft material formulations.

Key Features:

  • Library of machine learning operations that can be composed into pipelines
  • Pipelines are modular, visualizable, serializable, and self-documenting
  • Trivial support for multimodal data processing
  • All intermediate pipeline operations are stored in a xarray-based data model
  • Rich visualization tools for analyzing calculations

Installation

pip install git+https://github.com/usnistgov/afl-agent

Quick Start

Below is an example showcasing how to build a pipeline for choosing a sample composition

from AFL.double_agent import *
import numpy as np
import xarray as xr

with Pipeline() as pipeline:

    SavgolFilter(
        input_variable='measurement', 
        output_variable='derivative', 
        dim='x', 
        derivative=1
        )

    Similarity(
        input_variable='derivative', 
        output_variable='similarity', 
        params={'metric': 'cosine'}
        )

    SpectralClustering(
        input_variable='similarity',
        output_variable='labels',
        )

    GaussianProcessClassifier(
        feature_input_variable='composition',
        predictor_input_variable='labels',
        output_prefix='extrap',
    )

    MaxValueAF(
        input_variable='extrap_variance',
        output_variable='next_sample'
    )



# Generate synthetic data
n_samples = 10
n_points = 100
x = np.linspace(0, 10, n_points)
measurements = ... # data from your measurement
compositions = ... # composition of your samples

# Create dataset
ds = xr.Dataset(
    data_vars={
        'measurement': (['sample', 'x'], measurements),
        'composition': (['sample', 'components'], compositions)
    },
    coords={
        'x': x,
        'components': ['A', 'B', 'C']
    }
)

# Run the pipeline
ds_out = pipeline.calculate(ds)

#ds_out contains the following variables:
# - measurement: the original measurement data
# - derivative: the first derivative of the measurement data
# - similarity: the similarity between the samples
# - labels: the labels assigned to the samples
# - extrap_variance: the variance of the Gaussian process prediction
# - next_sample: the next sample to measure

Citation

If you use AFL-agent in your research, please cite the manuscript:

"Autonomous Small-Angle Scattering for Accelerated Soft Material Formulation Optimization" (under review)

Metadata

Release files for AFL-agent 1.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for AFL-agent 1.3.1
File Size Uploaded
afl_agent-1.3.1.tar.gz 366.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for AFL-agent 1.3.1
File Interpreter ABI Platform
afl_agent-1.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 768.1 kB

Release files / afl_agent-1.3.1.tar.gz

Download URL afl_agent-1.3.1.tar.gz
Size 366.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e9a650c40cbc1cc6f2f7ffae29eec08225103e2e8c4310d0f58d53d3e5368591
BLAKE2b-256 checksum
How to use checksums
ed234a032c01501183a96e2f0a51710633ee736d9e90bf9ca075af3fc03c4d17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 14, 2025.

Transparency log

Release files / afl_agent-1.3.1-py3-none-any.whl

Download URL afl_agent-1.3.1-py3-none-any.whl
Size 401.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
32e22224f466fa2b678576e0b5561647629780ada46e3f8d7f8305abd12ade7b
BLAKE2b-256 checksum
How to use checksums
0f27e5685607f10793177c71c005170a2fa69c1e9f3be21d6fdf36702dfc0a62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 14, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.3.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page