=======================
sampo.api.process_store
=======================

------
create
------

.. autofunction:: sampo.api.process_store.create

------------
open_process
------------

.. autofunction:: sampo.api.process_store.open_process

---------------------
list_process_metadata
---------------------

.. autofunction:: sampo.api.process_store.list_process_metadata

------------------
list_comp_metadata
------------------

.. autofunction:: sampo.api.process_store.list_comp_metadata

---------------
remove_process
---------------

.. autofunction:: sampo.api.process_store.remove_process

---------------
rename_process
---------------

.. autofunction:: sampo.api.process_store.rename_process

.. _convert_process:

---------------
convert_process
---------------

.. autofunction:: sampo.api.process_store.convert_process

.. _process-external-format:

~~~~~~~~~~~~~~~~~~~~~~~
Process External Format
~~~~~~~~~~~~~~~~~~~~~~~

Convertible data and their corresponding external format
--------------------------------------------------------

The convertible data and their corresponding external format are shown in the table below:

.. list-table::
    :header-rows: 1
    :widths: 1, 2

    * - Convertible Data
      - External Format
    * - SPD (SAMPO Process Description)
      - Same as SPD input file format.
        See the :ref:`SPD File Specification <spd>`.
    * - SRC (SAMPO Run Configuration)
      - Same as SRC input file format.
        See the :ref:`SRC File Specification <src>`.
    * - ASD (Attributes Schema Description)
      - Same as ASD input file format.
        See the :ref:`ASD File Specification <asd>`.
        The attributes in the ASD are component-specific. See component specification.
    * - Attribute metadata
      - See :ref:`Attribute Metadata File Specification <attribute-metadata>`
    * - Selected attributes
      - See :ref:`Selected Attributes File Specification<selected-attributes>`
    * - Model
      - A component-specific format. See each component specification.
    * - Component output data
      - Same as SAMPO CSV input file format.
        See the :doc:`SAMPO CSV File Specification <../../input/csv>`.
        The attributes in the output data are component-specific. See component specification.
    * - Prediction result evaluation
      - A component-specific format. See component specification.

.. _attribute-metadata:

Attribute Metadata File Format
------------------------------
* Attribute Metadata File describes the metadata of attributes and the derivation relations in a process.
* Attribute matadata is represented by DAG (Directed Acyclic Graph) structure, consisted of nodes and links.
      * Nodes section represents the information of each attribute.
      * Links section represents derivation relationships of attributes.
* The file follows the JSON format.

**Example**::

    {
        "nodes": [
            {"aid": "dl1[0]", "name": "A", "scale": "integer", "is_excluded": false,"cid": "dl1",
             "cindex": 0, "values": null, "is_kept": true, "context": null},
             {"aid": "dl1[1]", "name": "B", "scale": "nominal", "is_excluded": true, "cid": "dl1",
             "cindex": 1, "values": ["A", "B", "O"], "is_kept": true, "context": null},
             {"aid": "rg1[0]", "name": "actual", "scale": "real", "is_excluded": false, "cid": "rg1",
             "cindex": 0, "values": null, "is_kept": false, "context": {"field_path": ["regression", "actual"]}}
        ],
         "links": [
            {"source": "dl1[0]", "target": "rg1[0]"}
        ]
    }

Nodes Section
^^^^^^^^^^^^^
Nodes section represents the information of all attributes generated in a process.

Each property of attributes is defined as follows:

.. list-table::
    :header-rows: 1
    :widths: 10, 50

    * - Property
      - Description
    * - aid
      - Attribute ID.
    * - name
      - Attribute name.
    * - scale
      - Scale of the attribute.
    * - is_excluded
      - Whether the attribute is excluded as a feature or not.
    * - cid
      - ID of the component by which the attribute was generated.
    * - cindex
      - Index of the attribute in the component by which the attribute was generated.
    * - values
      - Domain of NOMINAL attribute. (**null** if the scale is not NOMINAL.)
    * - is_kept
      - Whether the attribute is kept or not even after running every component.
    * - context
      - Context information of the attribute.

Links Section
^^^^^^^^^^^^^
Links section represents derivation relationships of attributes::

    "links": [
        {"source": "dl1[0]", "target": "rg1[0]"}
    ]

In the above example, links section represents that the attribute **rg1[0]** was derived from the attribute **dl1[0]**.

|

Selected Attributes File Format
-------------------------------
* Selected Attributes contains the information of attributes which a learning component selected.
* The file follows the JSON format.

**Example**::

    {
        "selected_features": [
            {"aid": "dl1[0]", "name": "A", "scale": "integer", "is_excluded": false,
             "cid": "dl1", "cindex": 0, "values": null, "is_kept": false, "context": null},
            {"aid": "dl1[1]", "name": "B", "scale": "real", "is_excluded": false,
             "cid": "dl1", "cindex": 1, "values": null, "is_kept": false, "context": null},
            {"aid": "dl1[2]", "name": "C", "scale": "real", "is_excluded": false,
             "cid": "dl1", "cindex": 2, "values": null, "is_kept": false, "context": null}
        ],
        "selected_targets": [
            {"aid": "dl1[3]", "name": "Z", "scale": "integer", "is_excluded": true,
             "cid": "dl1", "cindex": 3, "values": null, "is_kept": true, "context": null}
        ]
    }

Selected Features Section
^^^^^^^^^^^^^^^^^^^^^^^^^
Selected Features Section describes attributes information selected as features.

Each property of attributes is defined as well as that in Nodes Section of Attribute Metadata.

Selected Targets Section
^^^^^^^^^^^^^^^^^^^^^^^^
Selected Targets Section describes attributes information selected as targets.

Each property of attributes is defined as well as that in Nodes Section of Attribute Metadata.

--------------
export_process
--------------

.. autofunction:: sampo.api.process_store.export_process

--------------
import_process
--------------

.. autofunction:: sampo.api.process_store.import_process

--------------
process_to_spd
--------------

.. autofunction:: sampo.api.process_store.process_to_spd
