> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mathfi.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Start training

> Creates a new training job for a dataset in `COMPLETED` status.

Training requires two hyperparameters:

| Parameter | Range | Description |
|---|---|---|
| `scalingFactor` | 0–499 | Controls the internal learning rate. Start with a value between 10 and 50 and tune from there. |
| `performanceThreshold` | 0.0–1.0 | Target balanced-class accuracy. Training stops when any algorithm reaches this value. Lower values complete faster. |

Multiple proprietary algorithms run in parallel and compete to reach `performanceThreshold`.
The winner algorithm produces the champion model.

Monitor progress via `GET /api/v1/training/{trainingJobKey}/progress`.




## OpenAPI

````yaml POST /api/v1/training/datasets/{datasetKey}
openapi: 3.0.1
info:
  title: MathFi.ai API
  description: >
    The MathFi.ai REST API lets you build predictive AI applications
    programmatically.


    Upload labelled CSV data, train a model, and run predictions — all in
    minutes.

    The API supports binary and multi-class classification on tabular data using

    Cellular Balanced Learning (CBL), running entirely on commodity CPUs.


    ## Base URL


    ```

    https://api.mathfi.ai

    ```


    ## Authentication


    All `/api/v1/*` endpoints require a Bearer token obtained from `POST
    /api/login`.

    Tokens are valid for **1 hour**. Re-authenticate when you receive a `401`.


    ```

    Authorization: Bearer <token>

    ```
  contact:
    name: MathFi.ai
    url: https://mathfi.ai
    email: support@mathfi.ai
  license:
    name: Mathficast Limited
    url: https://mathfi.ai
  version: 1.0.0
servers:
  - url: https://api.mathfi.ai
    description: Production
security:
  - BearerAuth: []
tags:
  - name: Authentication
    description: Obtain a Bearer token to authenticate API requests
  - name: Datasets
    description: Create and manage labelled training data in CSV format
  - name: Training
    description: Train models from datasets using a small set of hyperparameters
  - name: Models
    description: Inspect trained models and their performance metrics
  - name: Predictions
    description: Run inference on unseen data using trained models
paths:
  /api/v1/training/datasets/{datasetKey}:
    post:
      tags:
        - Training
      summary: Start training
      description: >
        Creates a new training job for a dataset in `COMPLETED` status.


        Training requires two hyperparameters:


        | Parameter | Range | Description |

        |---|---|---|

        | `scalingFactor` | 0–499 | Controls the internal learning rate. Start
        with a value between 10 and 50 and tune from there. |

        | `performanceThreshold` | 0.0–1.0 | Target balanced-class accuracy.
        Training stops when any algorithm reaches this value. Lower values
        complete faster. |


        Multiple proprietary algorithms run in parallel and compete to reach
        `performanceThreshold`.

        The winner algorithm produces the champion model.


        Monitor progress via `GET /api/v1/training/{trainingJobKey}/progress`.
      operationId: createTraining
      parameters:
        - name: datasetKey
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TrainingRequest'
            examples:
              Start training:
                summary: Start a training job
                value:
                  scalingFactor: 19
                  performanceThreshold: 0.85
      responses:
        '201':
          description: Training job created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TrainingJobCreationOutput'
        '400':
          description: Invalid training request or dataset not in COMPLETED status
        '500':
          description: Internal server error
components:
  schemas:
    TrainingRequest:
      required:
        - scalingFactor
        - performanceThreshold
      type: object
      properties:
        scalingFactor:
          type: integer
          format: int32
          minimum: 0
          maximum: 499
          description: |
            Controls the internal learning rate. A starting value of 10–50 works
            for most datasets. Adjust based on training performance progression.
          example: 19
        performanceThreshold:
          type: number
          format: double
          minimum: 0
          maximum: 1
          description: >
            Target balanced-class accuracy (0–1). Training stops when any
            algorithm

            reaches this value. Lower values complete faster. Typical starting
            point: 0.80.
          example: 0.85
    TrainingJobCreationOutput:
      required:
        - trainingJobKey
        - datasetKey
        - status
      type: object
      properties:
        trainingJobKey:
          type: string
          format: uuid
        datasetKey:
          type: string
          format: uuid
        status:
          $ref: '#/components/schemas/TrainingJobStatus'
        trainingJobProgressUrl:
          type: string
          description: URL to poll for training progress
    TrainingJobStatus:
      type: string
      description: >
        Status of a training job:


        | Status | Description |

        |---|---|

        | `PENDING` | Queued, not yet started |

        | `RUNNING` | Algorithms competing in parallel |

        | `COMPLETED` | Target performance reached. Champion model created. |

        | `TIMED_OUT` | Did not reach target performance within the time limit |

        | `NOT_COMPLETED` | Stalled — no progress detected for a sustained
        period |

        | `CANCELLED` | Cancelled by the user |

        | `FAILED` | Failed due to an internal error |
      enum:
        - PENDING
        - RUNNING
        - COMPLETED
        - TIMED_OUT
        - NOT_COMPLETED
        - CANCELLED
        - FAILED
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Obtain a token from `POST /api/login`. Valid for 1 hour.

````