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
python quickstart.py
Sample CSV files are provided in the sample_files/ directory, including a data file and example focus files for testing the demo.

Interactive Prompts

  1. API Endpoint: Your ArchetypeAI API endpoint (press Enter to use the default)
  2. Data File: Path to the CSV file containing sensor data to analyze
  3. Focus Files: Paths to example CSV files for each state you want to classify. Type done when finished adding files.
  4. Window Size: Number of data points per analysis window (default: 1024)
  5. Step Size: Number of data points to advance between windows (default: same as window size)

Example Session

=== Machine State Lens ===

Enter your API Endpoint (Press Enter for default):
Enter path to CSV to analyze: /Users/benxtan/Projects/ArchetypeAI/infer_sim5.csv

--- Add Focus Files ---
Provide CSV example(s) for each class (e.g., healthy.csv -> class 'healthy').
Type 'done' when finished.

Focus CSV path (or 'done'): /Users/benxtan/Projects/ArchetypeAI/healthy_sim5.csv
  Added: class 'healthy_sim5' from healthy_sim5.csv
Focus CSV path (or 'done'): done

Window size [default 1024]:
Step size   [default 1024]:

--- Configuration Summary ---
Lens ID:      lns-1d51909182270be2-bc1O8andqxf8b4os
API Endpoint: https://api.u1.archetypeai.app/v0.5
Data file:    /Users/benxtan/Projects/ArchetypeAI/infer_sim5.csv
Classes:      1
  - healthy_sim5: /Users/benxtan/Projects/ArchetypeAI/healthy_sim5.csv

Press Enter to start the analysis...
Session created: lsn-2b03144ecb0f022b5235b32734b308

Streaming...Press Ctrl+C to stop.

[1768401541.39556] -> Predicted class: ['healthy_sim5', {'healthy_sim5': 5}]
[1768401541.397359] -> Predicted class: ['healthy_sim5', {'healthy_sim5': 5}]
[1768401541.398611] -> Predicted class: ['healthy_sim5', {'healthy_sim5': 5}]
...
Stopped.
Session finished.

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

The window size parameter determines how many data points Newton analyzes in each inference cycle. This affects the granularity of state classification.
SettingValueUse Case
Default1024Optimal for most scenarios
High-frequency sensors (above 100Hz)256–512Finer granularity for fast-sampling data
Low-frequency sensors (below 10Hz)64–128Appropriate window for slower data
Maximum1024Upper limit for window size

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