How it works
- Machine State Lens running in Archetype platform for time-series classification
- CSV analysis with focus files sent to Newton for few-shot learning classification
- Google Sheets integration for real-time results logging and collaborative monitoring
- Two integration modes:
- File-to-Sheets: Run code in the terminal and log results in Sheets
- Spreadsheet-Driven: Control everything from Sheets
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 Setup.Install Conda
Setup dev environment
Install ATAI Python Library
Clone Cookbook Repository
Setup
Google API Configuration
To authenticate with Google Sheets, you’ll need OAuth 2.0 credentials. Follow the Google Sheets API Credentials Setup Guide to configure yourcredentials.json file.
Run Demos
Demo 1: Command Line to Sheets
Analyze local CSV files and automatically log results to Google Sheets.Running the Demo
From the Cookbook root directory with your conda environment activated:Interactive Prompts
- API Key: Your ArchetypeAI API key
- Google Sheets ID: Extract from your spreadsheet URL
- Data file: Path to CSV file to analyze (drag & drop supported) - you can use the files under
command-line-demos/machine-state/sample-files - Focus files: Example CSV files for each state class
Example Session
Demo 2: Spreadsheet-Driven
Control everything directly from Google Sheets - no need to interact with terminal once script is running.Setup Template
Create a pre-configured spreadsheet template:Running the Monitor
Start the monitoring script:Triggering Analysis
Prepare Your Data
- Open the Google Sheet created in the previous step
- Navigate to the Config sheet and add your API key in cell B1
- Import your sensor data:
- Click on the Data sheet tab
- Import your CSV data to analyze (File → Import → Upload)
- Ensure headers match:
timestamp,a1,a2,a3,a4
Add Focus Examples
- Create sheets for each machine state you want to classify
- Import example data for each state:
- Create/rename a sheet tab (e.g., “healthy”, “broken”)
- Import CSV data representing that state
- Repeat for each classification category
Start Analysis
- Return to the Config sheet
- Type “RUN” in cell B10
- Monitor progress in cell B11 (status updates)
- View results in the automatically created Results sheet
Real-time Monitoring
The script monitors cell B10 for triggers and updates status in B11:- “Ready” - Waiting for trigger
- “TRIGGERED” - Analysis starting
- “RUNNING - Processed X windows” - In progress
- “COMPLETED - Analyzed X windows” - Finished
- “ERROR - [details]” - Something went wrong
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.Recommended Settings
- 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