NanoEdge AI Emulator for n-class classification (nCC)

Warning white.png Warning

Update for NanoEdge AI v3.
Pay close attention to the new command names.


1. What is NanoEdge AI Library for n-class classification?

NanoEdge™ AI Library is an Artificial Intelligence (AI) static library originally developed by Cartesiam, for embedded C software running on Arm® Cortex® microcontrollers.

When embedded on microcontrollers, it gives them the ability to easily "classify" sensor patterns, by themselves, without the need for the user to have additional skills in Mathematics, Machine Learning, or data science.

The NanoEdge AI static library for n-class classification is the code that contains an AI model (for example, as a bundle of signal treatment, Machine Learning model, and optimally tuned hyperparameters) designed to determine which class a given sensor pattern belongs to. All classes are defined by the user in NanoEdge AI Studio (NanoEdgeAIStudio), also called the Studio, and are used during the training process of the AI model.

2. Purpose of NanoEdge AI Emulator for n-class classification

With NanoEdge AI Emulator, you can emulate the behavior of your NanoEdge AI Library (from the command line, or the interface provided through NanoEdge AI Studio), and start testing it as if it was running on your embedded application.

The emulator comes with each library created by the Studio. It has been compiled using the same algorithm. This means that for one library, there is one emulator. Using this tool, you can identify the class of your input signal as you would do in your embedded application.

3. NanoEdge AI Emulator functions

3.1. Get information (library id and name of classes)

The version of the emulator and the name of classes can be accessed at any time using neai_get_info.
The returned version number is the ID of the associated NanoEdge AI static library.

Usage:

./NanoEdgeAI_Class_Emulator neai_get_info               (Linux®)
NanoEdgeAI_Class_Emulator.exe neai_get_info           (Windows®)

Response:

{
   "lib_id": "5d5fd41ec8e0327c934",
   "class_name": ["unknown", "low", "medium", "high", "stop"]
}

3.2. Classification (inference)

There are two options to run the classification process: using an input file, or a sequence of values.

3.2.1. Classification by file

Usage:

  • By default all signals in input files are used:
./NanoEdgeAI_Class_Emulator neai_classification --knowledge_path knowledge.dat --file class_file.csv            (Linux®)
NanoEdgeAI_Class_Emulator.exe neai_classification --knowledge_path knowledge.dat --file class_file.csv       (Windows®)
  • But you can restrict the number of signals used (for instance, here, 10-14):
./NanoEdgeAI_Class_Emulator neai_classification --knowledge_path knowledge.dat --file class_file.csv --begin 10 --end 14   (Linux®)
NanoEdgeAI_Class_Emulator.exe neai_classification --knowledge_path knowledge.dat --file class_file.csv --begin 10 --end 14 (Windows®)

Arguments:

--knowledge_path:    path to the binary file containing the knowledge
--file:              path to the file containing data to classify
--begin:             number of the first data line in file (>= 1) (or of the first line to use)
--end:               number of the last data line in file (<= number of last line) (or of the last line to use)

Response:

{
   "status": "classification",
   "lib_id": "5d5fd41ec8e0327c934",
   "input": "../datasets/fan_testing_emulator.csv",
   "results": [
      {"signal": 1, "line": 10, "class_status": 1, "class_name": "low", "class_proba": [1.0000, 0.0000, 0.0000, 0.0000]},
      {"signal": 2, "line": 11, "class_status": 1, "class_name": "low", "class_proba": [0.9857, 0.0000, 0.0000, 0.0000]},
      {"signal": 3, "line": 12, "class_status": 2, "class_name": "medium", "class_proba": [0.0000, 1.0000, 0.0000, 0.0000]},
      {"signal": 4, "line": 13, "class_status": 3, "class_name": "high", "class_proba": [0.0000, 0.0000, 0.9987, 0.0000]},
      {"signal": 5, "line": 14, "class_status": 3, "class_name": "high", "class_proba": [0.0000, 0.0000, 1.0000, 0.0000]}
   ],
   "classification_summary": {"signals": 5, "classified": [2, 1, 2, 0], "unclassified": 0}
}

If an argument is missing, the following error message is returned:

Error: missing or not valid argument in NanoEdge AI classification function call by file !
Valid NanoEdge AI classification function calls by file are:
   neai_classification --knowledge_path path/knowledgefile --file path/testfile --begin line --end line
   neai_classification --knowledge_path path/knowledgefile --file path/testfile
Refer to NanoEdge AI Classification Emulator documentation for more details.
Warning white.png Warning

Your input file must have valid separators (, or ; or : or a single space or a single tab). If it is not the case, modify your input file. You can easily do so by first importing your file in NanoEdge AI Studio, then selecting the separator that you are currently using, and finally downloading it again by clicking NanoEdgeAI download icon.svg.

Also make sure to use periods (.) for decimal values, and NOT commas (,).

3.2.2. Classification by a sequence of values

Usage:

./NanoEdgeAI_Class_Emulator neai_classification --knowledge_path knowledge.dat --array value1 value2 ... valueN       (Linux®)
NanoEdgeAI_Class_Emulator.exe neai_classification --knowledge_path knowledge.dat --array value1 value2 ... valueN     (Windows®)

Arguments:

--array value1 value2 ... valueN       buffer composed of N numerical values, from *value1* to *valueN*

Response:

{
   "status": "classification",
   "input": "array",
   "results": [
      {"signal": 1, "line": "null", "class_status": 1, "class_name": "low", "class_proba": [1.0000, 0.0000, 0.0000, 0.0000]}
   ],
   "classification_summary": {"signals": 1, "classified": [1, 0, 0, 0], "unclassified": 0}
}

3.2.3. Remarks

  • The two classification modes (by file and by sequence of values) can be combined.
  • The binary file knowledge.dat is provided in the .zip file that you download by clicking Compile in NanoEdge AI Studio (on the "Deploy" screen which follows the "Optimize and Benchmark" and "Emulator" screens).
  • The header results shows the result of the classification process for each signal:
    • class_status is the identifier of the identified class
    • class_name is the name of the identified class
    • class_proba is an array with the probabilities of each class
  • The header classification_summary shows a summary of the last classification call.

4. Resources

Documentation
All NanoEdge AI Studio documentation is available here.

Tutorials
Step-by-step tutorials, to use NanoEdge AI Studio to build a smart device from A to Z.