# Workflow overview

## Introduction

Rather than offering a handful of static models, heartKIT provides a complete framework designed to cover the entire design process of creating customized ML models well-suited for low-power, wearable applications. Each mode serves a specific purpose and is engineered to offer you the flexibility and efficiency required for different tasks and use-cases.

Each `Task` implementes routines for each of the modes: [download](https://ambiqai.github.io/heartkit/modes/#download), [train](https://ambiqai.github.io/heartkit/modes/#train), [evaluate](https://ambiqai.github.io/heartkit/modes/#evaluate), [export](https://ambiqai.github.io/heartkit/modes/#export), and [demo](https://ambiqai.github.io/heartkit/modes/#demo). These modes are designed to streamline the process of training, evaluating, exporting, and running task-level demonstrations on the trained models.

---

## Choose a workflow step

| Step | Use it to | Guide |
| --- | --- | --- |
| Download | Fetch datasets into your configured directory. | [Download datasets](https://ambiqai.github.io/heartkit/modes/download/) |
| Train | Fit a model using your datasets, architecture and training settings. | [Train a model](https://ambiqai.github.io/heartkit/modes/train/) |
| Evaluate | Measure the trained model on held-out data. | [Evaluate a model](https://ambiqai.github.io/heartkit/modes/evaluate/) |
| Export | Convert a trained model for embedded inference. | [Export a model](https://ambiqai.github.io/heartkit/modes/export/) |
| Demo | Run a task demonstration on a PC or supported evaluation board. | [Run a demo](https://ambiqai.github.io/heartkit/modes/demo/) |

---

## [Download](https://ambiqai.github.io/heartkit/modes/download/)

[Download mode](https://ambiqai.github.io/heartkit/modes/download/) is used to download the specified datasets for the task. The routine can be customized via the configuration file or by setting the parameters directly in the code. The download process involves fetching the dataset(s) from the specified source and storing them in the specified directory.

## [Train](https://ambiqai.github.io/heartkit/modes/train/)

[Train mode](https://ambiqai.github.io/heartkit/modes/train/) is used to train a model for the specified task and dataset. In this mode, the model is trained for a given task using the specified dataset(s), model architecture, and hyperparameters. The training process involves optimizing the model's parameters to maximize its performance on the training data.

## [Evaluate](https://ambiqai.github.io/heartkit/modes/evaluate/)

[Evaluate mode](https://ambiqai.github.io/heartkit/modes/evaluate/) is used to test the performance of the model on the reserved test set for the specified task. The routine can be customized via the configuration file or by setting the parameters directly in the code. The evaluation process involves testing the model's performance on the test data to measure its accuracy, precision, recall, and F1 score.

## [Export](https://ambiqai.github.io/heartkit/modes/export/)

[Export mode](https://ambiqai.github.io/heartkit/modes/export/) is used to convert the trained model into a format that can be used for deployment onto Ambiq's family of SoCs. Currently, the command will convert the TensorFlow model into both TensorFlow Lite (TFL) and TensorFlow Lite for micro-controller (TFLM) variants. The command will also verify the models' outputs match.

## [Demo](https://ambiqai.github.io/heartkit/modes/demo/)

[Demo mode](https://ambiqai.github.io/heartkit/modes/demo/) is used to run a task-level demonstration on the trained model using the specified backend inference engine (e.g. PC or EVB). This is useful to showcase the model's performance in real-time and to verify its accuracy in a real-world scenario.
