Skip to main content

Prerequisites

The instructions below assume you are following best practices and have downloaded this git repo into a parent directory at: ~/atai. If you have already installed the ATAI Python Library and cloned the cookbook repository, proceed directly to Quickstart.
Before proceeding, check the requirements and correct Python version for the ATAI Python Library. To upgrade your Python client settings, please check our Python Client library.

Install Conda

wget https://repo.anaconda.com/archive/Anaconda3-2022.05-Linux-x86_64.sh
bash Anaconda3-2022.05-Linux-x86_64.sh
source ~/.bashrc

Setup dev environment

conda create -n dev_env python=3.10
conda activate dev_env

Install ATAI Python Library

git clone [email protected]:archetypeai/python-client.git
cd python-client
python -m pip install .

Clone Cookbook Repository

git clone https://github.com/archetypeai/archetypeai-cookbook.git

Quick Start

Analyze time-series sensor data to classify machine states using few-shot learning with example patterns.

Running the Demo

From the cookbook root directory with your conda environment activated:
cd command-line-demos/machine-state
pip install -r requirements.txt
python quickstart.py
Sample CSV files are provided in the sample-files/ directory, including a data file and example n-shot files for testing the demo.

Interactive Prompts

  1. API Key: Your API key
  2. Data File: Path to CSV file containing sensor data to analyze (drag & drop supported)
  3. N-shot files: Paths to example CSV files for each state you want to classify
  4. Window Configuration: Size and step parameters for analysis windows

Example Session

=== Machine State Analysis ===

Enter your ArchetypeAI API key: your-key-here

Enter path to data file: /path/to/sensor_data.csv

How many n-shot files? (examples of different states): 2

Focus file 1 (e.g., healthy.csv): /path/to/healthy.csv
Focus file 2 (e.g., broken.csv): /path/to/broken.csv

Window size (16-1024, default: auto): [Enter]
Step size (default: same as window): [Enter]

--- Configuration Summary ---
Data file: sensor_data.csv
N-shot files:
  - healthy.csv (class: healthy)
  - broken.csv (class: broken)
Window size: 256
Step size: 256

Press Enter to start analysis...

🔍 Analyzing time series data...

Results:
Window 1: healthy (confidence: 0.92)
Window 2: healthy (confidence: 0.88)
Window 3: broken (confidence: 0.95)

Sample Data

The demo includes sample files in the sample_files/ directory:
  • data.csv - Sensor data to analyze
  • focus/healthy.csv - Example of healthy machine state
  • focus/broken.csv - Example of broken machine state

Classification Tips

Naming Convention

Class names are automatically derived from focus file names:
  • healthy.csv creates class “healthy”
  • broken.csv creates class “broken”
  • normal_operation.csv creates class “normal_operation”

Window Size Configuration (to be reviewed)

The window size parameter determines how many data points Newton analyzes in each inference cycle. This affects the granularity of state classification.
  • Default: Auto-calculated based on focus file lengths
  • High-frequency sensors (greater than 100Hz): 256-512 points
  • Low-frequency sensors (less than 10Hz): 64-128 points
  • Maximum: 1024 points

How It Works

Each window represents a time segment of sensor data. The system compares these windows against your focus examples to classify the machine state. Non-overlapping windows (step size = window size) provide independent classifications, while overlapping windows offer smoother state transitions.

Constraints

  • Window size cannot exceed the length of your shortest focus file
  • Minimum window size is 16 data points for meaningful analysis